diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2014-04-21 20:58:34 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2014-04-21 20:58:34 -0700 |
| commit | 49d60b851cbff5339df53fde64a2accd993c4f1a (patch) | |
| tree | 06cf6784de423fd49911d72991b3d1a5a9ea7ec8 /src/libstd | |
| parent | 960bf8ce66d4d3563e1a03f2dbd161857ac0f398 (diff) | |
| download | rust-49d60b851cbff5339df53fde64a2accd993c4f1a.tar.gz rust-49d60b851cbff5339df53fde64a2accd993c4f1a.zip | |
str: Inline `only_ascii` in string iterators.
Was killing performance of selector matching in Servo.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/str.rs | 4 |
1 files changed, 4 insertions, 0 deletions
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 @@ impl<'a, C: CharEq> CharEq for &'a [C] { self.iter().any(|m| m.matches(c)) } + #[inline] fn only_ascii(&self) -> bool { self.iter().all(|m| m.only_ascii()) } |
