Skip to content

Repurpose Result#216

Merged
rovarga merged 2 commits intoPANTHEONtech:masterfrom
rovarga:no-result
Jan 25, 2025
Merged

Repurpose Result#216
rovarga merged 2 commits intoPANTHEONtech:masterfrom
rovarga:no-result

Conversation

@rovarga
Copy link
Collaborator

@rovarga rovarga commented Jan 23, 2025

Redesign this class to do what LookupResult used to do -- be just a
singleton indicator of restart. This allows us to ditch object
allocation from insert return paths.

Signed-off-by: Robert Varga robert.varga@pantheon.tech

The design of Result comes from original code as a replacement for
Optional. The thing is: we do not allow storage of nulls, hence we do
not have a use for a Optional.ofNullable() equivalent and therefore end
up allocating a result based on LNode/SNode value.

Make Result an enum with a single value RESTART, replacing
TrieMap.RESTART, just like we have had for LookupResult and switch
to using it for both lookup and insert cases.

The conversion is:
- null becomes 'RESTART' (with a static import)
- Result.empty() becomes 'null'
- Result.isPresent() becomes '!= null'
- Result.orNull() becomes nothing

Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
The if/return check can be simplified into an expression, let's take
advantage of that.

Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
@rovarga rovarga merged commit 0842609 into PANTHEONtech:master Jan 25, 2025
2 checks passed
@rovarga rovarga deleted the no-result branch January 25, 2025 02:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant