Speedup Build::clone
: Use Arc
instead of String
/PathBuf
/OsString
#782
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.
TBF, I'm not sure how much this will help real-world usage.
I submit this PR based on the observation that the APIs of
Build
accepts&str
,&Path
and&OsStr
, so converting them to anArc<T>
should be as cheap asString
/PathBuf
/OsString
given thatbuild-overrides
is compiled without optimization, so the compiler cannot simply omit these heap allocation (and even with optimization enabled-O3
, it's hard to do so).While
Arc::drop
is indeed due to atomic operations, I think this is mostly going to be ok given that the heap deallocation is likely to be more expensive than that sincebuild-overrides
uses platform-default allocator, which is often not the most optimized.Signed-off-by: Jiahao XU Jiahao_XU@outlook.com