Refactor walk and traverse to use arena-based node access#247
Open
bartveneman wants to merge 3 commits into
Open
Refactor walk and traverse to use arena-based node access#247bartveneman wants to merge 3 commits into
bartveneman wants to merge 3 commits into
Conversation
…cations
- Rewrite walk/traverse internals to navigate the arena directly using
integer indices (get_first_child/get_next_sibling) instead of going
through the first_child/next_sibling CSSNode getters for sibling
traversal bookkeeping
- Eliminate the { enter, leave } object created on every recursive call
in traverse — previously N extra allocations per traversal, now zero
- CSSNode wrappers are still created exactly once per visited node for
callback invocations; the root node passed in is reused as-is
- Add __get_source() and __get_index() internal helpers to CSSNode to
expose the arena index and source string needed by the new walker
https://claude.ai/code/session_01UVBKCBKB11qjh9k2PwbLen
Bundle ReportChanges will increase total bundle size by 1.48kB (0.78%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: @projectwallace/css-parser-esmAssets Changed:
Files in
Files in
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #247 +/- ##
==========================================
+ Coverage 93.14% 93.20% +0.06%
==========================================
Files 17 17
Lines 3035 3062 +27
Branches 845 853 +8
==========================================
+ Hits 2827 2854 +27
Misses 208 208 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Refactored the
walk()andtraverse()functions to directly access the CSS data arena instead of relying on node object properties. This change improves performance by avoiding repeated object property lookups and enables more efficient tree traversal.Key Changes
walk()function: Now extracts arena, source, and index from the node and uses arena methods (get_type(),get_first_child(),get_next_sibling()) for traversal instead of accessing node propertiestraverse()function: Similarly updated to use arena-based access for both enter and leave callbacks_walk()and_traverse()private functions that accept arena, source, and index parameters to avoid repeated extraction logic__get_source()and__get_index()methods to allow walk/traverse functions to access the underlying data needed for arena operationspackage-lock.jsonto ignore listImplementation Details
https://claude.ai/code/session_01UVBKCBKB11qjh9k2PwbLen