auto merge of #18203 : mahkoh/rust/cstring, r=thestinger
This is about 20x faster on my machine.
This commit is contained in:
commit
2130f22216
|
@ -275,15 +275,7 @@ impl Collection for CString {
|
||||||
/// Return the number of bytes in the CString (not including the NUL terminator).
|
/// Return the number of bytes in the CString (not including the NUL terminator).
|
||||||
#[inline]
|
#[inline]
|
||||||
fn len(&self) -> uint {
|
fn len(&self) -> uint {
|
||||||
let mut cur = self.buf;
|
unsafe { libc::strlen(self.buf) as uint }
|
||||||
let mut len = 0;
|
|
||||||
unsafe {
|
|
||||||
while *cur != 0 {
|
|
||||||
len += 1;
|
|
||||||
cur = cur.offset(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return len;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue