aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/attr.rs
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2015-07-04 18:41:47 -0700
committerCorey Farwell <coreyf@rwell.org>2015-07-08 04:42:49 +0900
commit9b2ba3d7134b4ec33c5a57e69faf48408d44ee74 (patch)
treea8b7d8210a7d1dc58ccb05005c66d99dee2d3e80 /components/script/dom/attr.rs
parent0688488a7fd3caee423968b33d6c19d79f94d29a (diff)
downloadservo-9b2ba3d7134b4ec33c5a57e69faf48408d44ee74.tar.gz
servo-9b2ba3d7134b4ec33c5a57e69faf48408d44ee74.zip
Join Atoms without requiring intermediate Vec
Related to: https://github.com/servo/string-cache/pull/89
Diffstat (limited to 'components/script/dom/attr.rs')
-rw-r--r--components/script/dom/attr.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/components/script/dom/attr.rs b/components/script/dom/attr.rs
index 0c8e92f7d42..a8f4b897f15 100644
--- a/components/script/dom/attr.rs
+++ b/components/script/dom/attr.rs
@@ -49,7 +49,11 @@ impl AttrValue {
}
pub fn from_atomic_tokens(atoms: Vec<Atom>) -> AttrValue {
- let tokens = atoms.iter().map(|x| &**x).collect::<Vec<_>>().connect("\x20");
+ let tokens = atoms.iter().fold(String::new(), |mut s, atom| {
+ if !s.is_empty() { s.push('\x20'); }
+ s.push_str(atom);
+ s
+ });
AttrValue::TokenList(tokens, atoms)
}