[diffs] reduce patch parsing string retention#686
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 937c550e76
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3dca8e4fe2
ℹ️ 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".
| } | ||
|
|
||
| if (!hasSurrogateCodeUnit(value)) { | ||
| return stringDetachDecoder.decode(stringDetachEncoder.encode(value)); |
There was a problem hiding this comment.
Preserve BOM when detaching string storage
Using TextDecoder with default options strips a leading UTF-8 BOM, so detachString() mutates valid content ("\uFEFF..." becomes "...") instead of just cloning backing storage. This commit routes parsed hunk lines, filenames, and metadata through detachString, so patches touching BOM-prefixed files lose the first character and produce incorrect parsed output.
Useful? React with 👍 / 👎.
This was definitely a moment of jesus take the wheel. I let codex go a bit deeper on figuring out how to optimize memory usage and performance when it came to parsing diffs.
I don't have the numbers but i think parsing was improved by at like 50% and memory usage scales immensely as the file size grows.
An example of improved memory usage:
BEFORE:

AFTER:
