Repository navigation
Conversation
Format TRAP entries straight into a byte buffer instead of buffering owned `Entry` values and formatting them at write time. Output is unchanged. Drop the now unused `Entry`, `Program` and `Display for Arg`, and take `comment` text by reference. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9ab88cf13c49431ab5be915077ce518e
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the TRAP writer memory-efficiency changes.
No open issues 🎉
What changed in this PR
This PR reduces allocation and memory overhead in the shared TRAP writer used by Rust, Ruby, QL, and unified extractors while preserving output formatting.
Changes:
- Formats entries directly into a byte buffer and removes unused intermediate types.
- Changes
commentto accept borrowed strings and updates callers. - Adds tests for output formatting and UTF-8 string truncation.
| File | Description |
|---|---|
| shared/tree-sitter-extractor/src/trap.rs | Implements byte-buffer formatting and adds regression tests. |
| shared/tree-sitter-extractor/src/extractor/mod.rs | Updates extraction callers for borrowed comments. |
| shared/tree-sitter-extractor/src/extractor/driver.rs | Updates test callers for borrowed comments. |
Review effort: Balanced (adaptive)
This branch has not been deployed
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.
Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
d4a55d1d80e9e3658e9045e4e7894d2d169c4ed3↑ Ruby
ast/controlflowQL tests (29/29) andql/ql/test(57/57) pass with the new extractors; extractor cargo tests pass.↓ Unified extractor only type-checked (no Swift toolchain locally); CI pending.
trap::Writerused to buffer ownedEntryvalues and format them only when writing the file. It now formats each entry straight into aVec<u8>as it is added, which avoids the per-entry allocations and keeps peak memory lower. This benefits every extractor using the shared crate (Rust, Ruby, QL, unified).Output is unchanged. The now-unused
Entry,ProgramandDisplay for Argare removed, andcommenttakes&str.add_tuplekeeps its signature, so generated code is untouched.Rough local measurements (user+sys CPU, before -> after):
index-files)