Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use simple traversal #217

Merged
merged 9 commits into from
Jan 25, 2025
Merged

Use simple traversal #217

merged 9 commits into from
Jan 25, 2025

Conversation

rovarga
Copy link
Collaborator

@rovarga rovarga commented Jan 24, 2025

This refactors out TrieMap.recLookup() and all MutableTrieMap mutators
so they descend the tree hierarchy via CNode/INode recursion, ending our
refactoring efforts.

The end delta since triemap-1.3.2 ends up being the break up of INode.rec*
methods driven by us choosing a different strategy enabled by
INode.gcasWrite() being exposed to the outside world -- thus any of
CNode/INode/LNode can use it as needed.

  • Add CNode.renew()
  • Add CNode.insert()
  • Move TrieMap.recLookup()
  • Refactor INode.lookup()
  • Split out {C,I}Node.remove()
  • Split out {C,I}Node.insert() and .insertIf()
  • Clean up MutableTrieMap method layout

We have three places which are doing the same thing, concentrate the bit
of logic into CNode.renew().

Signed-off-by: Robert Varga <[email protected]>
We have two places which are doing the same thing for insert(). Since we
have one alternative already existing, this moves the second piece from
MutableTrieMap to CNode.

Signed-off-by: Robert Varga <[email protected]>
Part one of splitting this method up again: move it to INode.

Signed-off-by: Robert Varga <[email protected]>
This breaks out CNode.lookup() with appropriate arguments to recurse
into INodes.

Signed-off-by: Robert Varga <[email protected]>
The two methods are cooperating, split them out from MutableTrieMap,
leading to a significant simplification of code.

Signed-off-by: Robert Varga <[email protected]>
The two methods are cooperating, which is obvious in
MutableTrieMap.recInsert() progress. Split that method up again, leading
to simpler code at each level.

It also allows us to reshuffle method placement and visibility a bit.

Signed-off-by: Robert Varga <[email protected]>
We have a few improvements that we can make:
- rename insertifhc() to insertIf() and move it below replace()
- rename removehc() to removeIf() and move it below insertIf()
- inline add() into SerializationProxy
- compute hc in insertIf()/removeIf()

Signed-off-by: Robert Varga <[email protected]>
Rather than passing as the last argument, always pass it as the first,
making for more navigable code.

Signed-off-by: Robert Varga <[email protected]>
Capture the type dispatch in CNode.elementSize() into a
Branch.elementSize(), which is then implemented by the two types.

As a consequence, the type safety of MainNode.size() is improved as
well.

Signed-off-by: Robert Varga <[email protected]>
@rovarga rovarga merged commit 0076327 into PANTHEONtech:master Jan 25, 2025
2 checks passed
@rovarga rovarga deleted the ww14 branch January 25, 2025 01: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