-
Notifications
You must be signed in to change notification settings - Fork 9
perf: using Arc<str> to share source content between source map #196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
94fcfda to
957c493
Compare
CodSpeed Performance ReportMerging #196 will improve performances by 13.1%Comparing Summary
Benchmarks breakdown
Footnotes
|
9f5b1c8 to
e99ef2b
Compare
e99ef2b to
dd0f92a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR optimizes memory usage by changing the internal representation of source content from String to Arc<str> throughout the codebase. This enables efficient string sharing and reduces allocations when the same source content is referenced multiple times.
Key Changes:
- Changed
SourceMap::sources_contentfromArc<[String]>toArc<[Arc<str>]> - Updated
OriginalSource::valueandSourceMapSource::original_sourceto useArc<str>instead ofString - Introduced
SourceContentLinesstruct using theself_cellcrate to manage self-referential data structures for cached line splitting
Reviewed Changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/source_map_source.rs | Updated original_source field type and simplified string conversions using .into() |
| src/source_content_lines.rs | Added new struct for efficiently managing source content split into lines with self-referential ownership |
| src/source.rs | Changed sources_content to use Arc<[Arc<str>]> and updated related methods |
| src/replace_source.rs | Refactored SourceContent enum and helper functions to work with Arc<str> and SourceContentLines |
| src/original_source.rs | Changed value field to Arc<str> and updated OnSource callback signature |
| src/lib.rs | Added module declaration for source_content_lines |
| src/helpers.rs | Updated helper functions, type signatures, and removed unused code |
| benches/bench.rs | Updated test data initialization to use .into() conversion |
| Cargo.toml | Added self_cell dependency |
| Cargo.lock | Added self_cell package entry |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This PR optimizes memory usage by changing the internal representation of source content from
StringtoArc<str>throughout the codebase. This enables efficient string sharing and reduces allocations when the same source content is referenced multiple times.Key Changes:
SourceMap::sources_contentfromArc<[String]>toArc<[Arc<str>]>OriginalSource::valueandSourceMapSource::original_sourceto useArc<str>instead ofStringSourceContentLinesstruct using theself_cellcrate to manage self-referential data structures for cached line splitting