mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #6556 - frewsxcv:AttrValue-from_serialized_tokenlist, r=Ms2ger
Utilize iterators for AttrValue::from_serialized_tokenlist <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6556) <!-- Reviewable:end -->
This commit is contained in:
commit
0fb6604cb3
1 changed files with 7 additions and 6 deletions
|
@ -38,12 +38,13 @@ pub enum AttrValue {
|
|||
|
||||
impl AttrValue {
|
||||
pub fn from_serialized_tokenlist(tokens: DOMString) -> AttrValue {
|
||||
let mut atoms: Vec<Atom> = vec!();
|
||||
for token in split_html_space_chars(&tokens).map(Atom::from_slice) {
|
||||
if !atoms.iter().any(|atom| *atom == token) {
|
||||
atoms.push(token);
|
||||
}
|
||||
}
|
||||
let atoms =
|
||||
split_html_space_chars(&tokens)
|
||||
.map(Atom::from_slice)
|
||||
.fold(vec![], |mut acc, atom| {
|
||||
if !acc.contains(&atom) { acc.push(atom) }
|
||||
acc
|
||||
});
|
||||
AttrValue::TokenList(tokens, atoms)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue