about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorUlrik Sverdrup <root@localhost>2015-06-24 16:22:09 +0200
committerUlrik Sverdrup <root@localhost>2015-06-24 16:22:09 +0200
commit274bb24efdbeed0ab1a91f3c02f86551ef16eac7 (patch)
tree274c90722829f1cb0b81aee5b176465737ec362d /src/libcore
parent71006bd6545015d7ae8e4c18589812bc1f6373dd (diff)
downloadrust-274bb24efdbeed0ab1a91f3c02f86551ef16eac7.tar.gz
rust-274bb24efdbeed0ab1a91f3c02f86551ef16eac7.zip
StrSearcher: Explicitly separate the long and short cases
This is needed to not drop performance, after the trait-based changes.
Force separate versions of the next method to be generated for the short
and long period cases.
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/str/pattern.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/libcore/str/pattern.rs b/src/libcore/str/pattern.rs
index 6d68615a8cf..dccdaa9120d 100644
--- a/src/libcore/str/pattern.rs
+++ b/src/libcore/str/pattern.rs
@@ -628,7 +628,7 @@ unsafe impl<'a, 'b> Searcher<'a> for StrSearcher<'a, 'b> {
         }
     }
 
-    #[inline]
+    #[inline(always)]
     fn next_match(&mut self) -> Option<(usize, usize)> {
         match self.searcher {
             StrSearcherImpl::Empty(..) => {
@@ -642,9 +642,15 @@ unsafe impl<'a, 'b> Searcher<'a> for StrSearcher<'a, 'b> {
             }
             StrSearcherImpl::TwoWay(ref mut searcher) => {
                 let is_long = searcher.memory == usize::MAX;
-                searcher.next::<MatchOnly>(self.haystack.as_bytes(),
-                                           self.needle.as_bytes(),
-                                           is_long)
+                if is_long {
+                    searcher.next::<MatchOnly>(self.haystack.as_bytes(),
+                                               self.needle.as_bytes(),
+                                               true)
+                } else {
+                    searcher.next::<MatchOnly>(self.haystack.as_bytes(),
+                                               self.needle.as_bytes(),
+                                               false)
+                }
             }
         }
     }
@@ -854,7 +860,7 @@ impl TwoWaySearcher {
     // left to right. If v matches, we try to match u by scanning right to left.
     // How far we can jump when we encounter a mismatch is all based on the fact
     // that (u, v) is a critical factorization for the needle.
-    #[inline]
+    #[inline(always)]
     fn next<S>(&mut self, haystack: &[u8], needle: &[u8], long_period: bool)
         -> S::Output
         where S: TwoWayStrategy