perf: combine source_contents scans in encode_to_string#289
Conversation
Combine the `.any()` check and the byte-length accumulation loop into a single `fold`, avoiding two iterations over `source_contents`. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Merging this PR will degrade performance by 1.08%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | serialize[real_small] |
4.4 µs | 4.3 µs | +1.42% |
| ⚡ | serialize[real_medium] |
5 µs | 4.9 µs | +2.38% |
| ⚡ | lookup_table[real_small] |
1.4 µs | 1.4 µs | +2.13% |
| ⚡ | lookup_table[real_medium] |
1.5 µs | 1.5 µs | +1.97% |
| ❌ | parse[real_medium] |
16.1 µs | 16.2 µs | -1.08% |
Comparing perf/combine-source-contents-scan (ae83d65) with main (b7fe1cf)
Footnotes
-
5 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ae83d655c5
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Summary
.any()check and the byte-length accumulation loop oversource_contentsinto a singlefold, avoiding two iterations over the collection during capacity estimation inencode_to_string.🤖 Generated with Claude Code