-
Notifications
You must be signed in to change notification settings - Fork 53
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
(feat) fast append for new node #92
(feat) fast append for new node #92
Conversation
Background: The use case for my project is to build up a parent pointing tree in the semantic analyzer: And after some profiling, we discovered some performance issues so hence this PR. |
I benchmarked locally with the latest 'fix' commit:
|
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #92 +/- ##
=======================================
+ Coverage 63.4% 64.0% +0.5%
=======================================
Files 8 8
Lines 471 470 -1
Branches 149 149
=======================================
+ Hits 299 301 +2
+ Misses 52 49 -3
Partials 120 120 |
@saschagrunert gentle ping Distilled questions:
|
Hey @YoniFeng, thank you for the PR! I generally think that it would be useful to extend the API to save some lines in user code. I'm happy with |
Only one is needed, I commit just to have both visible. |
PTAL / ready for submit AFAICT Do I need to squash commits? |
LGTM, thank you! |
I presume that building the tree and only then (possibly) mutating/transforming it, is the most common usage pattern (baseless presumption, but also confirmed for existing dependents like
pact-reference
).The current
Node.Id.append()
API isn't optimized for building up a tree from the ground up, where inserted nodes are new (therefore isolated/detached) and many of the checks and operations performed are redundant.I'd like to suggest adding an API to allow for quicker building up of the tree.
Would love to hear your thoughts.
Note
The initial commits are very crude. Would like to get feedback before proceeding.
I think a cleaner API for users might be some sort of
append_value
, where theT
value is supplied as an argument. Less verbose and hides the complexity (required assumptions).