Skip to content

Commit

Permalink
basicAt:ffAbsent: can be written in terms of #restoreValue: forKey: i…
Browse files Browse the repository at this point in the history
…terator:

-> we try to restore.
-> restore checks isRemoved
-> SoilIndexedDictionary>>#historicValueAt:iterator:ifAbsent:  does the isOlderThan: check

This way we use the same code for at: that we use for do:
  • Loading branch information
MarcusDenker committed Dec 4, 2023
1 parent 2116ec6 commit 09d1b97
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions src/Soil-Core/SoilIndexedDictionary.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -81,32 +81,7 @@ SoilIndexedDictionary >> basicAt: aString ifAbsent: aBlock [
key := (aString asSkipListKeyOfSize: self index keySize) asInteger.
iterator := self index newIterator.
value := iterator at: aString ifAbsent: aBlock.
value isRemoved ifTrue: [
^ (iterator currentPage isOlderThan: transaction readVersion)
ifTrue: [ aBlock value ]
ifFalse: [
(transaction
journalEntriesFor: key
inIndex: index
startingAt: iterator currentPage lastTransaction)
ifNotEmpty: [:entries |
entries last oldValue ]
ifEmpty: [ self halt. ] ] ].
"if the last modifying transaction of the current page is smaller
than ours then we don't need to check for visibility as all objects
are visible"
^ (iterator currentPage isOlderThan: transaction readVersion)
ifTrue: [ value ]
ifFalse: [
(transaction
journalEntriesFor: key
inIndex: index
startingAt: iterator currentPage lastTransaction)
ifNotEmpty: [:entries |
entries last oldValue ifNil: [ aBlock value ] ]
ifEmpty: [ value ].
]

^ (self restoreValue: value forKey: key iterator: iterator) ifNil: [ aBlock value ]
]

{ #category : #accessing }
Expand Down

0 comments on commit 09d1b97

Please sign in to comment.