mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-21 11:23:03 +00:00
Use strlen in CString::len
This commit is contained in:
parent
2fffbe0663
commit
4765bb9cb8
@ -275,15 +275,7 @@ impl Collection for CString {
|
||||
/// Return the number of bytes in the CString (not including the NUL terminator).
|
||||
#[inline]
|
||||
fn len(&self) -> uint {
|
||||
let mut cur = self.buf;
|
||||
let mut len = 0;
|
||||
unsafe {
|
||||
while *cur != 0 {
|
||||
len += 1;
|
||||
cur = cur.offset(1);
|
||||
}
|
||||
}
|
||||
return len;
|
||||
unsafe { libc::strlen(self.buf) as uint }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user