From de3e843d2467dff3ccb83efbae9260dc1b2a40bf Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Tue, 15 Dec 2015 00:03:42 +0100 Subject: Use memchr in libstd where possible, closes #30076 --- src/libstd/sys/unix/os.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/libstd/sys') diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index c2bf0651cff..12b9d6191a0 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -22,6 +22,7 @@ use io; use iter; use libc::{self, c_int, c_char, c_void}; use mem; +use memchr; use path::{self, PathBuf}; use ptr; use slice; @@ -406,7 +407,7 @@ pub fn env() -> Env { if input.is_empty() { return None; } - let pos = input[1..].iter().position(|&b| b == b'=').map(|p| p + 1); + let pos = memchr::memchr(b'=', &input[1..]).map(|p| p + 1); pos.map(|p| ( OsStringExt::from_vec(input[..p].to_vec()), OsStringExt::from_vec(input[p+1..].to_vec()), -- cgit 1.4.1-3-g733a5