mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Join Atoms without requiring intermediate Vec
Related to: https://github.com/servo/string-cache/pull/89
This commit is contained in:
parent
0688488a7f
commit
9b2ba3d713
1 changed files with 5 additions and 1 deletions
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue