-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Slightly optimise CString #37622
Slightly optimise CString #37622
Conversation
r? @brson (rust_highfive has picked a reviewer for you, use r? to override) |
Thanks for the PR! Are you worried about any particular function for |
Also, do you have benchmarks to back up the unsafe additions of eliding bounds checking? |
Not really, I just noticed that calling
I unfortunately haven't been able to see any difference from removing the bounds checks, only a possible tiny improvement from inlining. It probably doesn't matter much so I can remove it if you think it's too risky, I just noticed it in the assembly and thought we may as well remove some unnecessary instructions. |
We tend to avoid We also tend to prefer only using unsafe code for optimizations if we can show the improvement we're getting in perf, but if that's not the case here perhaps that could be backed out for now? |
Avoid a reallocation in CString::from and CStr::to_owned.
I've removed the inlining and bounds check removal. They weren't very important anyway. The use of |
@bors: r+ Yes |
📌 Commit 18f5f99 has been approved by |
Slightly optimise CString Avoid a reallocation in CString::from and CStr::to_owned.
Avoid a reallocation in CString::from and CStr::to_owned.