mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 10:01:13 +09:00
LibWeb: Port DOMStringMap from DeprecatedString to String
Porting name to FlyString as it is often compared in lookup, and in many cases, we already have a FlyString to supply anyway.
This commit is contained in:
parent
49a48fcfac
commit
9cd36839d2
Notes:
sideshowbarker
2024-07-16 20:12:13 +09:00
Author: https://github.com/shannonbooth
Commit: 9cd36839d2
Pull-request: https://github.com/SerenityOS/serenity/pull/22057
Reviewed-by: https://github.com/trflynn89
2 changed files with 8 additions and 8 deletions
|
@ -82,7 +82,7 @@ Vector<DOMStringMap::NameValuePair> DOMStringMap::get_name_value_pairs() const
|
|||
builder.append(current_character);
|
||||
}
|
||||
|
||||
list.append({ builder.to_deprecated_string(), value });
|
||||
list.append({ MUST(builder.to_string()), MUST(String::from_deprecated_string(value)) });
|
||||
});
|
||||
|
||||
// 4. Return list.
|
||||
|
@ -97,18 +97,18 @@ Vector<String> DOMStringMap::supported_property_names() const
|
|||
Vector<String> names;
|
||||
auto name_value_pairs = get_name_value_pairs();
|
||||
for (auto& name_value_pair : name_value_pairs) {
|
||||
names.append(MUST(String::from_deprecated_string(name_value_pair.name)));
|
||||
names.append(name_value_pair.name.to_string());
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/dom.html#dom-domstringmap-nameditem
|
||||
DeprecatedString DOMStringMap::determine_value_of_named_property(DeprecatedString const& name) const
|
||||
String DOMStringMap::determine_value_of_named_property(FlyString const& name) const
|
||||
{
|
||||
// To determine the value of a named property name for a DOMStringMap, return the value component of the name-value pair whose name component is name in the list returned from getting the
|
||||
// DOMStringMap's name-value pairs.
|
||||
auto name_value_pairs = get_name_value_pairs();
|
||||
auto optional_value = name_value_pairs.first_matching([&name](NameValuePair& name_value_pair) {
|
||||
auto optional_value = name_value_pairs.first_matching([&name](NameValuePair const& name_value_pair) {
|
||||
return name_value_pair.name == name;
|
||||
});
|
||||
|
||||
|
@ -199,7 +199,7 @@ WebIDL::ExceptionOr<Bindings::LegacyPlatformObject::DidDeletionFail> DOMStringMa
|
|||
|
||||
WebIDL::ExceptionOr<JS::Value> DOMStringMap::named_item_value(FlyString const& name) const
|
||||
{
|
||||
return JS::PrimitiveString::create(vm(), determine_value_of_named_property(name.to_deprecated_fly_string()));
|
||||
return JS::PrimitiveString::create(vm(), determine_value_of_named_property(name));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue