about summary refs log tree commit diff
path: root/src/libstd/sys_common
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-09-18 17:30:29 +0000
committerbors <bors@rust-lang.org>2017-09-18 17:30:29 +0000
commit0701b37d97d08da7074ece7a7dcb4449498f4bfa (patch)
tree796f1ce756d1bce72a8462d6d74c28f11263895c /src/libstd/sys_common
parent3a7b960731fd1cf86f1879b1a0d44196a0917c53 (diff)
parent929215db7c598722410709022e69f71702f02e0b (diff)
downloadrust-0701b37d97d08da7074ece7a7dcb4449498f4bfa.tar.gz
rust-0701b37d97d08da7074ece7a7dcb4449498f4bfa.zip
Auto merge of #44678 - alexcrichton:rollup, r=alexcrichton
Rollup of 11 pull requests

- Successful merges: #44364, #44466, #44537, #44548, #44640, #44651, #44657, #44661, #44668, #44671, #44675
- Failed merges:
Diffstat (limited to 'src/libstd/sys_common')
-rw-r--r--src/libstd/sys_common/memchr.rs9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/libstd/sys_common/memchr.rs b/src/libstd/sys_common/memchr.rs
index 3824a5fb528..50f998eb486 100644
--- a/src/libstd/sys_common/memchr.rs
+++ b/src/libstd/sys_common/memchr.rs
@@ -65,15 +65,12 @@ pub mod fallback {
         let usize_bytes = mem::size_of::<usize>();
 
         // search up to an aligned boundary
-        let align = (ptr as usize) & (usize_bytes- 1);
-        let mut offset;
-        if align > 0 {
-            offset = cmp::min(usize_bytes - align, len);
+        let mut offset = ptr.align_offset(usize_bytes);
+        if offset > 0 {
+            offset = cmp::min(offset, len);
             if let Some(index) = text[..offset].iter().position(|elt| *elt == x) {
                 return Some(index);
             }
-        } else {
-            offset = 0;
         }
 
         // search the body of the text