-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Cleanup strs #7996
Cleanup strs #7996
Conversation
* to full strings, or suffixes of them. | ||
*/ | ||
#[inline] | ||
fn as_mut_buf<T>(&self, f: &fn(*mut u8, uint) -> T) -> T { |
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.
This should probably have a warning about maintaining the invariant that the string is valid UTF8, and should definitely take &mut self
rather than &self
.
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.
Thanks for catching that. I'll add the &mut self
and a warning.
@huonw: Updated the pull request address your suggestion, and also added a couple more cleanup functions. |
I would think (The whole matter of null termination remains, to this day, contentious. As you know, in #7235) |
These uses are assuming the strings are null terminated, so it should be using `as_c_str` instead of `as_buf`
This eliminates a copy and fixes a FIXME.
@graydon: Updated the pull request to add |
This is a cleanup pull request that does: * removes `os::as_c_charp` * moves `str::as_buf` and `str::as_c_str` into `StrSlice` * converts some functions from `StrSlice::as_buf` to `StrSlice::as_c_str` * renames `StrSlice::as_buf` to `StrSlice::as_imm_buf` (and adds `StrSlice::as_mut_buf` to match `vec.rs`. * renames `UniqueStr::as_bytes_with_null_consume` to `UniqueStr::to_bytes` * and other misc cleanups and minor optimizations
…arth Add test case for RESULT_MAP_OR_INTO_OPTION just added test case for RESULT_MAP_OR_INTO_OPTION. changelog: none
This is a cleanup pull request that does:
os::as_c_charp
str::as_buf
andstr::as_c_str
intoStrSlice
StrSlice::as_buf
toStrSlice::as_c_str
StrSlice::as_buf
toStrSlice::as_imm_buf
(and addsStrSlice::as_mut_buf
to matchvec.rs
.UniqueStr::as_bytes_with_null_consume
toUniqueStr::to_bytes