perf(core): clone row template and slice active rows#4904
Draft
lukecotter wants to merge 1 commit into
Draft
Conversation
Row.createElement clones a shared template element instead of running createElement + classList.add + setAttribute per row. RowManager.setActiveRows copies with Array.slice() instead of Object.assign([], ...) (and drops a dead self-assignment), avoiding the slow generic-property copy path on large datasets.
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
Two small allocation reductions on core hot paths, both behaviour-preserving.
Changes
Row.createElementclones a shared template element (cloneNode(false)) instead of runningcreateElement+classList.add+setAttributefor every row.RowManager.setActiveRowscopies withArray.slice()instead ofObject.assign([], activeRows)(and drops a dead double self-assignment).Object.assign([], arr)falls onto V8's generic property-copy path and is dramatically slower thanslice()on large arrays; this runs on every pipeline pass.Benchmarks (Node, 250k rows, median of trials)
Row.createElement250k: +41% (1.7×)setActiveRowscopy: +99% (≈166×) — removes a ~23ms hitch per pipeline pass on large datasets.Tests
Full unit suite green. No behaviour change.