aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/namespace.rs
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2013-12-09 15:10:09 +0000
committerSimon Sapin <simon.sapin@exyr.org>2013-12-09 15:10:09 +0000
commit61c7f2f22026bfa043192eeeea7292ab219214c3 (patch)
treef59ded7b2c4d5aa2c815040ecc5d754471fc99d7 /src/components/script/dom/namespace.rs
parent28575c20bfc0cf8040333428451fdecd32a4bca5 (diff)
downloadservo-61c7f2f22026bfa043192eeeea7292ab219214c3.tar.gz
servo-61c7f2f22026bfa043192eeeea7292ab219214c3.zip
Change Namespace::to_str() to not allocate and return a reference.
Diffstat (limited to 'src/components/script/dom/namespace.rs')
-rw-r--r--src/components/script/dom/namespace.rs30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/components/script/dom/namespace.rs b/src/components/script/dom/namespace.rs
index fb255d90419..c446b2969d6 100644
--- a/src/components/script/dom/namespace.rs
+++ b/src/components/script/dom/namespace.rs
@@ -19,26 +19,26 @@ pub enum Namespace {
impl Namespace {
pub fn from_str(url: Option<DOMString>) -> Namespace {
match null_str_as_empty_ref(&url) {
- &"http://www.w3.org/1999/xhtml" => HTML,
- &"http://www.w3.org/XML/1998/namespace" => XML,
- &"http://www.w3.org/2000/xmlns/" => XMLNS,
- &"http://www.w3.org/1999/xlink" => XLink,
- &"http://www.w3.org/2000/svg" => SVG,
- &"http://www.w3.org/1998/Math/MathML" => MathML,
- &"" => Null,
+ "http://www.w3.org/1999/xhtml" => HTML,
+ "http://www.w3.org/XML/1998/namespace" => XML,
+ "http://www.w3.org/2000/xmlns/" => XMLNS,
+ "http://www.w3.org/1999/xlink" => XLink,
+ "http://www.w3.org/2000/svg" => SVG,
+ "http://www.w3.org/1998/Math/MathML" => MathML,
+ "" => Null,
ns => Other(ns.to_owned())
}
}
- pub fn to_str(&self) -> Option<DOMString> {
+ pub fn to_str<'a>(&'a self) -> Option<&'a str> {
match *self {
Null => None,
- HTML => Some(~"http://www.w3.org/1999/xhtml"),
- XML => Some(~"http://www.w3.org/XML/1998/namespace"),
- XMLNS => Some(~"http://www.w3.org/2000/xmlns/"),
- XLink => Some(~"http://www.w3.org/1999/xlink"),
- SVG => Some(~"http://www.w3.org/2000/svg"),
- MathML => Some(~"http://www.w3.org/1998/Math/MathML"),
- Other(ref x) => Some(x.to_owned())
+ HTML => Some("http://www.w3.org/1999/xhtml"),
+ XML => Some("http://www.w3.org/XML/1998/namespace"),
+ XMLNS => Some("http://www.w3.org/2000/xmlns/"),
+ XLink => Some("http://www.w3.org/1999/xlink"),
+ SVG => Some("http://www.w3.org/2000/svg"),
+ MathML => Some("http://www.w3.org/1998/Math/MathML"),
+ Other(ref x) => Some(x.as_slice())
}
}
}