Skip to content

Commit 9b2ba3d

Browse files
committed
Join Atoms without requiring intermediate Vec
Related to: servo/string-cache#89
1 parent 0688488 commit 9b2ba3d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

components/script/dom/attr.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ impl AttrValue {
4949
}
5050

5151
pub fn from_atomic_tokens(atoms: Vec<Atom>) -> AttrValue {
52-
let tokens = atoms.iter().map(|x| &**x).collect::<Vec<_>>().connect("\x20");
52+
let tokens = atoms.iter().fold(String::new(), |mut s, atom| {
53+
if !s.is_empty() { s.push('\x20'); }
54+
s.push_str(atom);
55+
s
56+
});
5357
AttrValue::TokenList(tokens, atoms)
5458
}
5559

0 commit comments

Comments
 (0)