Skip to content

perf: speed up Selection.Text by outlining recursion#561

Merged
mna merged 1 commit into
PuerkitoBio:masterfrom
jvoisin:noclosure
May 28, 2026
Merged

perf: speed up Selection.Text by outlining recursion#561
mna merged 1 commit into
PuerkitoBio:masterfrom
jvoisin:noclosure

Conversation

@jvoisin
Copy link
Copy Markdown
Contributor

@jvoisin jvoisin commented May 27, 2026

Replace the recursive closure in Selection.Text with a helper method call. This keeps behavior unchanged while reducing runtime overhead in the hot path.

Benchmark (BenchmarkText, benchstat, n=12):

  • sec/op: 2.133us -> 1.692us (-20.70%, p=0.000)
  • B/op: 504 -> 504 (no change)
  • allocs/op: 6 -> 6 (no change)

Replace the recursive closure in Selection.Text with a helper method call.
This keeps behavior unchanged while reducing runtime overhead in the hot path.

Benchmark (BenchmarkText, benchstat, n=12):
- sec/op: 2.133us -> 1.692us (-20.70%, p=0.000)
- B/op: 504 -> 504 (no change)
- allocs/op: 6 -> 6 (no change)
@mna mna merged commit 59eb206 into PuerkitoBio:master May 28, 2026
6 checks passed
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