Skip to content

Keep the pending children of a render node in its children field - #269

Merged
FlorianRappl merged 3 commits into
AngleSharp:develfrom
michaelthyregod:feature/render-node-children
Nov 5, 2026
Merged

FlorianRappl merged 3 commits into
AngleSharp:develfrom
michaelthyregod:feature/render-node-children

Conversation

@michaelthyregod

Copy link
Copy Markdown
Contributor

Follow-up to #267, for your field count there: with this a complete render node has exactly the fields it had before #267 (+0 instead of +1).

ElementRenderNode._children now holds either the children (a complete tree, as before) or, in a partial render tree, the PendingChildren that build them on first read. PendingChildren also caches the children it builds, with the same Volatile.Read + Interlocked.CompareExchange publish as before. Children costs one type check against a sealed class.

No public API changes: the signature of Children and the public constructor are the same; the rest is private or inside the internal RenderTreeBuilder.

Benchmarks (BenchmarkDotNet, 6 alternating rounds, pinned to the performance cores):

vs devel before #267 (3defd6d) vs devel now (#267) Allocations
Render(), real-world document (8,645 element nodes) +0.8% +1.8% same as before #267 (39,629 KB)
Render(), selector-heavy document (112,865 element nodes) +0.5% −1.4% same as before #267 (352,031 KB)
CssCascade RenderTree +1.6% +0.2% same as before #267

All differences are within the noise of single rounds (±5%); the allocations of a full Render() are back at what they were before #267.

🤖 Generated with Claude Code

A complete render node is back to the fields it had before AngleSharp#267: the children field holds either the children or, in a partial render tree, what builds them on first read.
@CLAassistant

CLAassistant commented Nov 5, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@FlorianRappl FlorianRappl added this to the v1.4.0 milestone Nov 5, 2026
@FlorianRappl
FlorianRappl merged commit df89ed3 into AngleSharp:devel Nov 5, 2026
5 checks passed
@michaelthyregod
michaelthyregod deleted the feature/render-node-children branch November 5, 2026 10:11
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.

3 participants