From 1b90f6ac83094dc3cb61178a3590e4a83146289b Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Sun, 25 Feb 2018 17:17:03 -0800 Subject: [PATCH] Remove unnecessary 'do_match_until' function. --- lib/src/router/collider.rs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/lib/src/router/collider.rs b/lib/src/router/collider.rs index cd9945b0..baa8e048 100644 --- a/lib/src/router/collider.rs +++ b/lib/src/router/collider.rs @@ -12,7 +12,7 @@ pub trait Collider { } #[inline(always)] -fn do_match_iter_until(break_c: u8, mut a: A, mut b: B) -> bool +fn iters_match_until(break_c: u8, mut a: A, mut b: B) -> bool where A: Iterator, B: Iterator { loop { @@ -27,21 +27,13 @@ fn do_match_iter_until(break_c: u8, mut a: A, mut b: B) -> bool } } -#[inline(always)] -fn do_match_until(break_c: u8, a: &str, b: &str, dir: bool) -> bool { - let (a_iter, b_iter) = (a.as_bytes().iter().cloned(), b.as_bytes().iter().cloned()); - if dir { - do_match_iter_until(break_c, a_iter, b_iter) - } else { - do_match_iter_until(break_c, a_iter.rev(), b_iter.rev()) - } -} - impl<'a> Collider for &'a str { #[inline(always)] fn collides_with(&self, other: &str) -> bool { - let (a, b) = (self, other); - do_match_until(b'<', a, b, true) && do_match_until(b'>', a, b, false) + let a_iter = self.as_bytes().iter().cloned(); + let b_iter = other.as_bytes().iter().cloned(); + iters_match_until(b'<', a_iter.clone(), b_iter.clone()) + && iters_match_until(b'>', a_iter.rev(), b_iter.rev()) } }