@@ -358,9 +358,7 @@ extension DiskPersistence.Transaction: DatastoreInterfaceProtocol {
358358 rootObject: rootManifest
359359 )
360360 createdRootObjects. insert ( newRootObject)
361- if createdRootObjects. contains ( existingRootObject) {
362- createdRootObjects. remove ( existingRootObject)
363- } else {
361+ if createdRootObjects. remove ( existingRootObject) == nil {
364362 deletedRootObjects. insert ( existingRootObject)
365363 }
366364 await datastore. adopt ( rootObject: newRootObject)
@@ -925,14 +923,12 @@ extension DiskPersistence.Transaction {
925923 let datastore = existingRootObject. datastore
926924
927925 /// 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+ }
936932
937933 /// No change occured, bail early
938934 guard existingIndex. id. manifestID != indexManifest. id else { return }
@@ -949,9 +945,7 @@ extension DiskPersistence.Transaction {
949945 manifest: indexManifest
950946 )
951947 createdIndexes. insert ( newIndex)
952- if createdIndexes. contains ( existingIndex) {
953- createdIndexes. remove ( existingIndex)
954- } else {
948+ if createdIndexes. remove ( existingIndex) == nil {
955949 deletedIndexes. insert ( existingIndex)
956950 }
957951 await datastore. adopt ( index: newIndex)
@@ -972,9 +966,7 @@ extension DiskPersistence.Transaction {
972966 rootObject: rootManifest
973967 )
974968 createdRootObjects. insert ( newRootObject)
975- if createdRootObjects. contains ( existingRootObject) {
976- createdRootObjects. remove ( existingRootObject)
977- } else {
969+ if createdRootObjects. remove ( existingRootObject) == nil {
978970 deletedRootObjects. insert ( existingRootObject)
979971 }
980972 await datastore. adopt ( rootObject: newRootObject)
@@ -1043,9 +1035,7 @@ extension DiskPersistence.Transaction {
10431035 manifest: indexManifest
10441036 )
10451037 createdIndexes. insert ( newIndex)
1046- if createdIndexes. contains ( existingIndex) {
1047- createdIndexes. remove ( existingIndex)
1048- } else {
1038+ if createdIndexes. remove ( existingIndex) == nil {
10491039 deletedIndexes. insert ( existingIndex)
10501040 }
10511041 await datastore. adopt ( index: newIndex)
@@ -1066,9 +1056,7 @@ extension DiskPersistence.Transaction {
10661056 rootObject: rootManifest
10671057 )
10681058 createdRootObjects. insert ( newRootObject)
1069- if createdRootObjects. contains ( existingRootObject) {
1070- createdRootObjects. remove ( existingRootObject)
1071- } else {
1059+ if createdRootObjects. remove ( existingRootObject) == nil {
10721060 deletedRootObjects. insert ( existingRootObject)
10731061 }
10741062 await datastore. adopt ( rootObject: newRootObject)
@@ -1119,9 +1107,7 @@ extension DiskPersistence.Transaction {
11191107 manifest: indexManifest
11201108 )
11211109 createdIndexes. insert ( newIndex)
1122- if createdIndexes. contains ( existingIndex) {
1123- createdIndexes. remove ( existingIndex)
1124- } else {
1110+ if createdIndexes. remove ( existingIndex) == nil {
11251111 deletedIndexes. insert ( existingIndex)
11261112 }
11271113 await datastore. adopt ( index: newIndex)
@@ -1140,9 +1126,7 @@ extension DiskPersistence.Transaction {
11401126 rootObject: rootManifest
11411127 )
11421128 createdRootObjects. insert ( newRootObject)
1143- if createdRootObjects. contains ( existingRootObject) {
1144- createdRootObjects. remove ( existingRootObject)
1145- } else {
1129+ if createdRootObjects. remove ( existingRootObject) == nil {
11461130 deletedRootObjects. insert ( existingRootObject)
11471131 }
11481132 await datastore. adopt ( rootObject: newRootObject)
@@ -1227,9 +1211,7 @@ extension DiskPersistence.Transaction {
12271211 rootObject: rootManifest
12281212 )
12291213 createdRootObjects. insert ( newRootObject)
1230- if createdRootObjects. contains ( existingRootObject) {
1231- createdRootObjects. remove ( existingRootObject)
1232- } else {
1214+ if createdRootObjects. remove ( existingRootObject) == nil {
12331215 deletedRootObjects. insert ( existingRootObject)
12341216 }
12351217 await datastore. adopt ( rootObject: newRootObject)
@@ -1310,9 +1292,7 @@ extension DiskPersistence.Transaction {
13101292 rootObject: rootManifest
13111293 )
13121294 createdRootObjects. insert ( newRootObject)
1313- if createdRootObjects. contains ( existingRootObject) {
1314- createdRootObjects. remove ( existingRootObject)
1315- } else {
1295+ if createdRootObjects. remove ( existingRootObject) == nil {
13161296 deletedRootObjects. insert ( existingRootObject)
13171297 }
13181298 await datastore. adopt ( rootObject: newRootObject)
0 commit comments