From f20ed830a780744606af96f36dbdbaefb5bd2646 Mon Sep 17 00:00:00 2001 From: Marcus Denker Date: Fri, 8 Dec 2023 10:32:28 +0100 Subject: [PATCH] this uses the #do of the SoilIndexedDictionary in size, this way it is can restore values correctly on the level of the SoilIndexedDictionary. fixes #527 --- src/Soil-Core-Tests/SoilIndexedDictionaryTest.class.st | 4 +--- src/Soil-Core/SoilIndexedDictionary.class.st | 7 ++++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Soil-Core-Tests/SoilIndexedDictionaryTest.class.st b/src/Soil-Core-Tests/SoilIndexedDictionaryTest.class.st index 011ccbb2..52f98124 100644 --- a/src/Soil-Core-Tests/SoilIndexedDictionaryTest.class.st +++ b/src/Soil-Core-Tests/SoilIndexedDictionaryTest.class.st @@ -239,9 +239,7 @@ SoilIndexedDictionaryTest >> testConcurrentIsEmpty [ tx3 commit. "invisible: tx2 still has the key" self deny: tx2 root isEmpty. - "to fix: size is wrong as it does not restore the value" - self flag: #isRemoved. - self assert: tx2 root size equals: 0 + self assert: tx2 root size equals: 1 ] { #category : #tests } diff --git a/src/Soil-Core/SoilIndexedDictionary.class.st b/src/Soil-Core/SoilIndexedDictionary.class.st index 7fb77d76..1805e740 100644 --- a/src/Soil-Core/SoilIndexedDictionary.class.st +++ b/src/Soil-Core/SoilIndexedDictionary.class.st @@ -339,7 +339,12 @@ SoilIndexedDictionary >> second [ { #category : #accessing } SoilIndexedDictionary >> size [ ^ transaction - ifNotNil: [ self index size ] + ifNotNil: [ + "We should just call size on index, but the do: here can restore values" + | sum | + sum := 0. + self do: [ :each | sum := sum + 1 ]. + sum ] ifNil: [ newValues size ] ]