about summary refs log tree commit diff
path: root/src/libstd/sys
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-12-19 00:57:25 +0000
committerbors <bors@rust-lang.org>2015-12-19 00:57:25 +0000
commit8ad12c3e251df6b8ed42b4d32709f4f55470a0be (patch)
tree0b89a14f1590e2537f5aa796092364438014d249 /src/libstd/sys
parent9e278950c2243f0d8e6638678359139a22d7e427 (diff)
parenta206e556d07134661eba5cbb0315fbd59c3e6717 (diff)
downloadrust-8ad12c3e251df6b8ed42b4d32709f4f55470a0be.tar.gz
rust-8ad12c3e251df6b8ed42b4d32709f4f55470a0be.zip
Auto merge of #30381 - fhahn:memchr-in-std, r=alexcrichton
This PR adds `memchr`and `memrchr` based on @BurntSushi 's rust-memchr crate to libstd (as discussed in #30151).

I've update some places in libstd to use memchr/memrchr, but I am not sure if there are other places where it could be used as well.

ref #30076
Diffstat (limited to 'src/libstd/sys')
-rw-r--r--src/libstd/sys/unix/os.rs3
1 files changed, 2 insertions, 1 deletions
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()),