Skip to content

Commit 2130f22

Browse files
committed
auto merge of #18203 : mahkoh/rust/cstring, r=thestinger
This is about 20x faster on my machine.
2 parents 4764c16 + 4765bb9 commit 2130f22

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

src/librustrt/c_str.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -275,15 +275,7 @@ impl Collection for CString {
275275
/// Return the number of bytes in the CString (not including the NUL terminator).
276276
#[inline]
277277
fn len(&self) -> uint {
278-
let mut cur = self.buf;
279-
let mut len = 0;
280-
unsafe {
281-
while *cur != 0 {
282-
len += 1;
283-
cur = cur.offset(1);
284-
}
285-
}
286-
return len;
278+
unsafe { libc::strlen(self.buf) as uint }
287279
}
288280
}
289281

0 commit comments

Comments
 (0)