@@ -358,9 +358,7 @@ extension DiskPersistence.Transaction: DatastoreInterfaceProtocol {
358
358
rootObject: rootManifest
359
359
)
360
360
createdRootObjects. insert ( newRootObject)
361
- if createdRootObjects. contains ( existingRootObject) {
362
- createdRootObjects. remove ( existingRootObject)
363
- } else {
361
+ if createdRootObjects. remove ( existingRootObject) == nil {
364
362
deletedRootObjects. insert ( existingRootObject)
365
363
}
366
364
await datastore. adopt ( rootObject: newRootObject)
@@ -925,14 +923,12 @@ extension DiskPersistence.Transaction {
925
923
let datastore = existingRootObject. datastore
926
924
927
925
/// Depending on the cursor type, insert or replace the entry in the index, capturing the new manifesr, added and removed pages, and change in the number of entries.
928
- let ( ( indexManifest, newPages, removedPages) , newEntryCount) = try await {
929
- switch try cursor ( for: someCursor) {
930
- case . insertion( let cursor) :
931
- return ( try await existingIndex. manifest ( inserting: entry, at: cursor) , 1 )
932
- case . instance( let cursor) :
933
- return ( try await existingIndex. manifest ( replacing: entry, at: cursor) , 0 )
934
- }
935
- } ( )
926
+ let ( ( indexManifest, newPages, removedPages) , newEntryCount) = switch try cursor ( for: someCursor) {
927
+ case . insertion( let cursor) :
928
+ ( try await existingIndex. manifest ( inserting: entry, at: cursor) , 1 )
929
+ case . instance( let cursor) :
930
+ ( try await existingIndex. manifest ( replacing: entry, at: cursor) , 0 )
931
+ }
936
932
937
933
/// No change occured, bail early
938
934
guard existingIndex. id. manifestID != indexManifest. id else { return }
@@ -949,9 +945,7 @@ extension DiskPersistence.Transaction {
949
945
manifest: indexManifest
950
946
)
951
947
createdIndexes. insert ( newIndex)
952
- if createdIndexes. contains ( existingIndex) {
953
- createdIndexes. remove ( existingIndex)
954
- } else {
948
+ if createdIndexes. remove ( existingIndex) == nil {
955
949
deletedIndexes. insert ( existingIndex)
956
950
}
957
951
await datastore. adopt ( index: newIndex)
@@ -972,9 +966,7 @@ extension DiskPersistence.Transaction {
972
966
rootObject: rootManifest
973
967
)
974
968
createdRootObjects. insert ( newRootObject)
975
- if createdRootObjects. contains ( existingRootObject) {
976
- createdRootObjects. remove ( existingRootObject)
977
- } else {
969
+ if createdRootObjects. remove ( existingRootObject) == nil {
978
970
deletedRootObjects. insert ( existingRootObject)
979
971
}
980
972
await datastore. adopt ( rootObject: newRootObject)
@@ -1043,9 +1035,7 @@ extension DiskPersistence.Transaction {
1043
1035
manifest: indexManifest
1044
1036
)
1045
1037
createdIndexes. insert ( newIndex)
1046
- if createdIndexes. contains ( existingIndex) {
1047
- createdIndexes. remove ( existingIndex)
1048
- } else {
1038
+ if createdIndexes. remove ( existingIndex) == nil {
1049
1039
deletedIndexes. insert ( existingIndex)
1050
1040
}
1051
1041
await datastore. adopt ( index: newIndex)
@@ -1066,9 +1056,7 @@ extension DiskPersistence.Transaction {
1066
1056
rootObject: rootManifest
1067
1057
)
1068
1058
createdRootObjects. insert ( newRootObject)
1069
- if createdRootObjects. contains ( existingRootObject) {
1070
- createdRootObjects. remove ( existingRootObject)
1071
- } else {
1059
+ if createdRootObjects. remove ( existingRootObject) == nil {
1072
1060
deletedRootObjects. insert ( existingRootObject)
1073
1061
}
1074
1062
await datastore. adopt ( rootObject: newRootObject)
@@ -1119,9 +1107,7 @@ extension DiskPersistence.Transaction {
1119
1107
manifest: indexManifest
1120
1108
)
1121
1109
createdIndexes. insert ( newIndex)
1122
- if createdIndexes. contains ( existingIndex) {
1123
- createdIndexes. remove ( existingIndex)
1124
- } else {
1110
+ if createdIndexes. remove ( existingIndex) == nil {
1125
1111
deletedIndexes. insert ( existingIndex)
1126
1112
}
1127
1113
await datastore. adopt ( index: newIndex)
@@ -1140,9 +1126,7 @@ extension DiskPersistence.Transaction {
1140
1126
rootObject: rootManifest
1141
1127
)
1142
1128
createdRootObjects. insert ( newRootObject)
1143
- if createdRootObjects. contains ( existingRootObject) {
1144
- createdRootObjects. remove ( existingRootObject)
1145
- } else {
1129
+ if createdRootObjects. remove ( existingRootObject) == nil {
1146
1130
deletedRootObjects. insert ( existingRootObject)
1147
1131
}
1148
1132
await datastore. adopt ( rootObject: newRootObject)
@@ -1227,9 +1211,7 @@ extension DiskPersistence.Transaction {
1227
1211
rootObject: rootManifest
1228
1212
)
1229
1213
createdRootObjects. insert ( newRootObject)
1230
- if createdRootObjects. contains ( existingRootObject) {
1231
- createdRootObjects. remove ( existingRootObject)
1232
- } else {
1214
+ if createdRootObjects. remove ( existingRootObject) == nil {
1233
1215
deletedRootObjects. insert ( existingRootObject)
1234
1216
}
1235
1217
await datastore. adopt ( rootObject: newRootObject)
@@ -1310,9 +1292,7 @@ extension DiskPersistence.Transaction {
1310
1292
rootObject: rootManifest
1311
1293
)
1312
1294
createdRootObjects. insert ( newRootObject)
1313
- if createdRootObjects. contains ( existingRootObject) {
1314
- createdRootObjects. remove ( existingRootObject)
1315
- } else {
1295
+ if createdRootObjects. remove ( existingRootObject) == nil {
1316
1296
deletedRootObjects. insert ( existingRootObject)
1317
1297
}
1318
1298
await datastore. adopt ( rootObject: newRootObject)
0 commit comments