Skip to content
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

Changed from String to Arc<str> where value is constant + Touch documentation #77

Merged
merged 3 commits into from
Jan 31, 2025

Conversation

Leif-Rydenfalk
Copy link
Contributor

We've switched from String to Arc<str> for constant values, and it's mainly about performance:

  1. Reduced Memory Allocation:

    • With 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.
    • By using Arc<str>, we share the same string across different parts of the code, cutting down on these allocations.
  2. 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.
  3. 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.

@wtholliday wtholliday merged commit 97fbdef into audulus:main Jan 31, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants