mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:17:44 +00:00
LibWeb: Use split_view() in attribute selector matching
Using split() creates a new String object for each of the split tokens. Use split_view() instead to avoid these unnecessary heap allocations.
This commit is contained in:
parent
dc26c02379
commit
d78a007b5d
1 changed files with 2 additions and 2 deletions
|
@ -35,13 +35,13 @@ static bool matches_attribute(CSS::Selector::SimpleSelector::Attribute const& at
|
|||
return element.attribute(attribute.name) == attribute.value;
|
||||
break;
|
||||
case CSS::Selector::SimpleSelector::Attribute::MatchType::ContainsWord:
|
||||
return element.attribute(attribute.name).split(' ').contains_slow(attribute.value);
|
||||
return element.attribute(attribute.name).split_view(' ').contains_slow(attribute.value);
|
||||
break;
|
||||
case CSS::Selector::SimpleSelector::Attribute::MatchType::ContainsString:
|
||||
return element.attribute(attribute.name).contains(attribute.value);
|
||||
break;
|
||||
case CSS::Selector::SimpleSelector::Attribute::MatchType::StartsWithSegment:
|
||||
return element.attribute(attribute.name).split('-').first() == attribute.value;
|
||||
return element.attribute(attribute.name).split_view('-').first() == attribute.value;
|
||||
break;
|
||||
case CSS::Selector::SimpleSelector::Attribute::MatchType::StartsWithString:
|
||||
return element.attribute(attribute.name).starts_with(attribute.value);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue