diff options
author | Ms2ger <ms2ger@gmail.com> | 2015-05-01 21:20:16 +0200 |
---|---|---|
committer | Ms2ger <ms2ger@gmail.com> | 2015-05-01 21:20:16 +0200 |
commit | bd77acfbb87a7ac8e987e38c14f26441fb0de64f (patch) | |
tree | c98aaabc5c183190461fb354bc87a44961c5a715 /components/script/dom/bindings/str.rs | |
parent | 5f6b791e626b1a012665b917cb9173ceaf5f4bcc (diff) | |
download | servo-bd77acfbb87a7ac8e987e38c14f26441fb0de64f.tar.gz servo-bd77acfbb87a7ac8e987e38c14f26441fb0de64f.zip |
Use AsciiExt in ByteString implementations.
Diffstat (limited to 'components/script/dom/bindings/str.rs')
-rw-r--r-- | components/script/dom/bindings/str.rs | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/components/script/dom/bindings/str.rs b/components/script/dom/bindings/str.rs index 4b275baa934..b8c0af0caa6 100644 --- a/components/script/dom/bindings/str.rs +++ b/components/script/dom/bindings/str.rs @@ -4,6 +4,7 @@ //! The `ByteString` struct. +use std::ascii::AsciiExt; use std::borrow::ToOwned; use std::hash::{Hash, Hasher}; use std::ops; @@ -36,20 +37,12 @@ impl ByteString { /// Compare `self` to `other`, matching A–Z and a–z as equal. pub fn eq_ignore_case(&self, other: &ByteString) -> bool { - // XXXManishearth make this more efficient - self.to_lower() == other.to_lower() + self.0.eq_ignore_ascii_case(&other.0) } /// Returns `self` with A–Z replaced by a–z. pub fn to_lower(&self) -> ByteString { - let ByteString(ref vec) = *self; - ByteString::new(vec.iter().map(|&x| { - if x > 'A' as u8 && x < 'Z' as u8 { - x + ('a' as u8) - ('A' as u8) - } else { - x - } - }).collect()) + ByteString::new(self.0.to_ascii_lowercase()) } /// Returns whether `self` is a `token`, as defined by |