Skip to content

perf: Add property-to-index Map for O(1) lookups in _getIndexOf#288

Closed
domenic wants to merge 1 commit intomainfrom
perf/property-index-map
Closed

perf: Add property-to-index Map for O(1) lookups in _getIndexOf#288
domenic wants to merge 1 commit intomainfrom
perf/property-index-map

Conversation

@domenic
Copy link
Member

@domenic domenic commented Jan 9, 2026

Replaces the O(n) linear search in _getIndexOf with an O(1) Map lookup. The _propertyIndices Map is maintained alongside the indexed properties to track each property's position.

🤖 Generated with Claude Code


To-do before merging:

  • Human code review (@asamuzaK welcome to help)
  • Double-check benchmark improvements manually
  • Double-check the full jsdom test suite passes

Replaces the O(n) linear search in _getIndexOf with an O(1) Map lookup.
The _propertyIndices Map is maintained alongside the indexed properties
to track each property's position.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
asamuzaK added a commit to asamuzaK/cssstyle that referenced this pull request Jan 9, 2026
@asamuzaK
Copy link
Contributor

asamuzaK commented Jan 9, 2026

Wouldn't it be better to separate the functions as originally used, rather than repeating the for loop multiple times?
See #291

asamuzaK added a commit to asamuzaK/cssstyle that referenced this pull request Jan 9, 2026
asamuzaK added a commit to asamuzaK/cssstyle that referenced this pull request Jan 9, 2026
@domenic
Copy link
Member Author

domenic commented Jan 10, 2026

Agreed, #291 is better; will close this.

@domenic domenic closed this Jan 10, 2026
@domenic domenic deleted the perf/property-index-map branch January 10, 2026 02:19
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.

2 participants

Comments