diff --git a/ReStore/SSWDBOwnedCollectionSpec.cls b/ReStore/SSWDBOwnedCollectionSpec.cls index a9497a5..a95e134 100644 --- a/ReStore/SSWDBOwnedCollectionSpec.cls +++ b/ReStore/SSWDBOwnedCollectionSpec.cls @@ -47,12 +47,21 @@ deleteQuery yourself! elementsIn: aCollection notIn: anotherCollection - - ^aCollection reject: [ :each | anotherCollection identityIncludes: each]! + | testAgainst | + "For small collections, the IdentitySet is actually slower, so just stick with the original collection in that common case." + testAgainst := anotherCollection size < 10 + ifTrue: [anotherCollection] + ifFalse: [anotherCollection asIdentitySet]. + ^aCollection reject: [:each | testAgainst identityIncludes: each].! hasCollection: updatedCollection anyAdditionsOrRemovalsFrom: originalCollection - - ^updatedCollection size ~= originalCollection size or: [updatedCollection anySatisfy: [ :each | (originalCollection identityIncludes: each) not]]! + | testAgainst | + updatedCollection size = originalCollection size ifFalse: [^true]. + "For small collections, the IdentitySet is actually slower, so just stick with the original collection in that common case." + testAgainst := originalCollection size < 10 + ifTrue: [originalCollection] + ifFalse: [originalCollection asIdentitySet]. + ^updatedCollection anySatisfy: [:each | (testAgainst identityIncludes: each) not].! orderingSpecs