From 9b2ba3d7134b4ec33c5a57e69faf48408d44ee74 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sat, 4 Jul 2015 18:41:47 -0700 Subject: [PATCH] Join Atoms without requiring intermediate Vec Related to: https://github.com/servo/string-cache/pull/89 --- components/script/dom/attr.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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) -> AttrValue { - let tokens = atoms.iter().map(|x| &**x).collect::>().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) }