]> git.lizzy.rs Git - rust.git/commitdiff
str: Inline `only_ascii` in string iterators.
authorPatrick Walton <pcwalton@mimiga.net>
Tue, 22 Apr 2014 03:58:34 +0000 (20:58 -0700)
committerPatrick Walton <pcwalton@mimiga.net>
Tue, 22 Apr 2014 03:58:34 +0000 (20:58 -0700)
Was killing performance of selector matching in Servo.

src/libstd/str.rs

index 3c03bddb293ed8bc4fb7cc48a454ecc330a93b15..f537022cdf6dc4734a5db7757502a4be7e12121b 100644 (file)
@@ -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())
     }