From 49d60b851cbff5339df53fde64a2accd993c4f1a Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Mon, 21 Apr 2014 20:58:34 -0700 Subject: [PATCH] str: Inline `only_ascii` in string iterators. Was killing performance of selector matching in Servo. --- src/libstd/str.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libstd/str.rs b/src/libstd/str.rs index 3c03bddb293..f537022cdf6 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -227,6 +227,7 @@ impl CharEq for char { #[inline] fn matches(&self, c: char) -> bool { *self == c } + #[inline] fn only_ascii(&self) -> bool { (*self as uint) < 128 } } @@ -234,6 +235,7 @@ impl<'a> CharEq for |char|: 'a -> bool { #[inline] fn matches(&self, c: char) -> bool { (*self)(c) } + #[inline] fn only_ascii(&self) -> bool { false } } @@ -241,6 +243,7 @@ impl CharEq for extern "Rust" fn(char) -> bool { #[inline] fn matches(&self, c: char) -> bool { (*self)(c) } + #[inline] fn only_ascii(&self) -> bool { false } } @@ -250,6 +253,7 @@ fn matches(&self, c: char) -> bool { self.iter().any(|m| m.matches(c)) } + #[inline] fn only_ascii(&self) -> bool { self.iter().all(|m| m.only_ascii()) } -- 2.44.0