Changed from String to Arc<str> where value is constant + Touch documentation #77
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.
We've switched from
String
toArc<str>
for constant values, and it's mainly about performance:Reduced Memory Allocation:
String
, we end up allocating and deallocating memory every time a new string is created or dropped. For values that don’t change, this is unnecessary overhead.Arc<str>
, we share the same string across different parts of the code, cutting down on these allocations.Avoiding Unnecessary Copies:
String
requires cloning if it’s being passed around multiple places, which increases memory usage and adds a performance hit.Arc<str>
lets us share the same data without copying, thanks to its reference counting.Thread-Safe and Efficient:
Arc<str>
is thread-safe, so we can safely use the same string across multiple threads without extra locking, which is especially useful when the data is constant and won’t change.Overall, this change helps make the code faster and more memory efficient by avoiding redundant allocations and copying, while keeping things thread-safe.
Note
The creator of this pull request states that it is ready to be merged from his side.