Skip to content

Visit a lone child straight away and skip the excess-attribute check when nothing changed - #206

Merged
joeldrapper merged 1 commit into
claude/project-thread-pjcqpbfrom
claude/project-thread-7y3nfe
Oct 10, 2026
Merged

joeldrapper merged 1 commit into
claude/project-thread-pjcqpbfrom
claude/project-thread-7y3nfe

Conversation

@joeldrapper

@joeldrapper joeldrapper commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Requested by Joel · project thread

Before: editing a deep tree (200 × depth 10) took 18.5 ms in Chromium, 3.6x morphdom's 5.2 ms, because every level built the sibling matcher and ran all its passes for a single child.

After: the same edit takes 7.8 ms (1.5x morphdom). Tables of 500 rows are 17–18% faster and a tiny text edit 31% faster. Other scenarios are unchanged within noise. Matching results don't change.

How:

  • When both sides have exactly one child, it's an element of the same kind that only the kind pass can match (no id, not a form control, no name), and nothing in the morph holds the user's changes, every pass would pair the two. So #morphChildNodes visits the child directly instead of building Siblings.
  • #visitAttributes notes whether every target attribute was already there with the same value. With equal attribute counts there can't be any excess, so hasExcessAttributes is skipped.

Benchmark (Chromium, lower quartile of 21 rounds, against #205's head):

Scenario #205 This PR morphdom
deep 200 × depth 10 edit 18.5 ms 7.8 ms (−58%) 5.2 ms
table 500 keyed edit all 17.7 ms 14.5 ms (−18%) 10.4 ms
table 500 unkeyed edit all 15.4 ms 12.8 ms (−17%) 8.4 ms
tiny text edit 0.026 ms 0.018 ms (−31%) 0.004 ms

Stacked on #205. The full suite passes with 100% coverage, plus deep local fuzz runs (5,000 tree seeds and the matching, preserve, move and form fuzzers).

🤖 Generated with Claude Code

https://claude.ai/code/session_01VJNvudrTrB2rfJaLWKRMsc

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T16:09:35.983650Z 738339e New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@joeldrapper
joeldrapper added this pull request to stack #207 October 8, 2026 16:57
@joeldrapper
joeldrapper force-pushed the claude/project-thread-7y3nfe branch 2 times, most recently from b2a7079 to 3544956 Compare October 9, 2026 15:58
…when nothing changed

When both sides have one child element of the same kind that only the kind pass
can match, and nothing in the morph holds the user's changes, every pass would
pair the two, so the child is visited without building the sibling matcher.
The attribute pass also knows when every target attribute was already there;
with equal counts there's nothing to remove.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VJNvudrTrB2rfJaLWKRMsc
@joeldrapper
joeldrapper force-pushed the claude/project-thread-7y3nfe branch from 3544956 to 738339e Compare October 9, 2026 16:07
@joeldrapper
joeldrapper merged commit b6f5b2e into main Oct 10, 2026
7 checks passed
@joeldrapper
joeldrapper deleted the claude/project-thread-7y3nfe branch October 10, 2026 06:59
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