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

Use compact_str instead of String as Schema's field #245

Open
fjchen7 opened this issue Aug 4, 2024 · 0 comments
Open

Use compact_str instead of String as Schema's field #245

fjchen7 opened this issue Aug 4, 2024 · 0 comments

Comments

@fjchen7
Copy link

fjchen7 commented Aug 4, 2024

It seems that in most cases, the Schema's field are not very long. The atc-router sets it as String, which allocates memory on the heap during each initialization and cloning.

In this scenario, I suggest using compact_str instead of String. CompactString from compact_str is a mutable string, but it has a great feature: when the string is less than 24 bytes (which I believe should cover most cases), it will be stored on the stack. This is more efficient than performing operations on the heap during initialization or cloning.

Similarly, some field of Match and Context can also be modified.

Considering that there are numerous String clones in the code, I think using compact_str instead could bring a noticeable improvement in efficiency.

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

No branches or pull requests

1 participant