about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorJulian Orth <ju.orth@gmail.com>2014-10-21 08:12:50 +0200
committerJulian Orth <ju.orth@gmail.com>2014-10-21 08:12:50 +0200
commit4765bb9cb87bcac5fecc0f02cea5dc0eca1c347d (patch)
treede9893ad616bf89801da9b9c66118a4e066bcff4 /src
parent2fffbe06635dcaa17ce34dcfde9a42f0aaf52be0 (diff)
downloadrust-4765bb9cb87bcac5fecc0f02cea5dc0eca1c347d.tar.gz
rust-4765bb9cb87bcac5fecc0f02cea5dc0eca1c347d.zip
Use strlen in CString::len
Diffstat (limited to 'src')
-rw-r--r--src/librustrt/c_str.rs10
1 files changed, 1 insertions, 9 deletions
diff --git a/src/librustrt/c_str.rs b/src/librustrt/c_str.rs
index a4129fe3506..0ef0601828d 100644
--- a/src/librustrt/c_str.rs
+++ b/src/librustrt/c_str.rs
@@ -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 }
     }
 }