Don't create queue in WeakDom::insert for leaf instances #463
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a fast path for leaf instances to
WeakDom::insert
. When an instance does not have any children, then we don't need to create a queue, avoiding a heap allocation, and can perform the insertion then exit the method immediately.On my machine, this improves rbx_binary's "Deserialize 10,000 Parts" benchmark by ~4%, and reduces the number of heap allocations by ~7%. Note that the effectiveness of this optimization depends on how many leaf instances the requested insertion has, so this improvement is probably overstated on this benchmark, which contains vastly more leaf instances than internal instances.