-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Implement cstr_count_bytes
#114443
Implement cstr_count_bytes
#114443
Conversation
r? @cuviper (rustbot has picked a reviewer for you, use r? to override) |
@rustbot label -T-libs |
I gated the constness under |
526250e
to
21f91cf
Compare
Does it make sense for the |
Yeah, that's definitely up for debate. I mentioned in the not reviewed ACP (rust-lang/libs-team#256) that I just wouldn't want to surprise users with "hey, this used to be faster but now it's O(1)!" whenever we do make that change. But I also can't imagine that affecting many people (and time complexity of other things would be changing anyway). |
dedde83
to
c39b686
Compare
As recommended on the ACP, I changed this to use the constant time length but add the warning in the docs that this will change |
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #115009) made this pull request unmergeable. Please resolve the merge conflicts. |
Currently, `CStr::from_ptr` contains its own implementation of `strlen` that uses `const_eval_select` to either call libc's `strlen` or use a naive Rust implementation. Refactor that into its own function so we can use it elsewhere in the module.
This is feature gated under `cstr_count_bytes` and provides a more straightforward way to access the length of a `CStr` Link: rust-lang#113219
Marking as
S-waiting-on-ACP
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
@bors r+ |
Thanks! |
☀️ Test successful - checks-actions |
Finished benchmarking commit (3b9e0fe): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 631.334s -> 632.311s (0.15%) |
This has not yet been approved via ACP, but it's simple enough to get started on.
CStr::count_bytes()
method libs-team#256cstr_count_bytes
#114441@rustbot label +T-libs-api