1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:07:34 +00:00

LibWeb: Use from_deprecated_fly_string() instead of from_utf8()

Use FlyString::from_deprecated_fly_string() in these instances instead
of FlyString::from_utf8(). As we convert to new FlyString/String we want
to be aware of these potential unnecessary allocations.
This commit is contained in:
Kenneth Myhra 2023-03-09 18:07:49 +01:00 committed by Linus Groh
parent e28a6d5da4
commit be958a14cf
4 changed files with 7 additions and 7 deletions

View file

@ -291,7 +291,7 @@ Parser::ParseErrorOr<Selector::SimpleSelector> Parser::parse_attribute_simple_se
// they are converted to lowercase, so we do that here too. If we want to be
// correct with XML later, we'll need to keep the original case and then do
// a case-insensitive compare later.
.name = FlyString::from_utf8(attribute_part.token().ident().to_lowercase_string()).release_value_but_fixme_should_propagate_errors(),
.name = FlyString::from_deprecated_fly_string(attribute_part.token().ident().to_lowercase_string()).release_value_but_fixme_should_propagate_errors(),
.case_type = Selector::SimpleSelector::Attribute::CaseType::DefaultMatch,
}
};

View file

@ -32,7 +32,7 @@ static inline bool matches_lang_pseudo_class(DOM::Element const& element, Vector
for (auto const* e = &element; e; e = e->parent_element()) {
auto lang = e->attribute(HTML::AttributeNames::lang);
if (!lang.is_null()) {
element_language = FlyString::from_utf8(lang).release_value_but_fixme_should_propagate_errors();
element_language = FlyString::from_deprecated_fly_string(lang).release_value_but_fixme_should_propagate_errors();
break;
}
}

View file

@ -175,14 +175,14 @@ Vector<MatchingRule> StyleComputer::collect_matching_rules(DOM::Element const& e
};
for (auto const& class_name : element.class_names()) {
if (auto it = rule_cache.rules_by_class.find(FlyString::from_utf8(class_name).release_value_but_fixme_should_propagate_errors()); it != rule_cache.rules_by_class.end())
if (auto it = rule_cache.rules_by_class.find(class_name); it != rule_cache.rules_by_class.end())
add_rules_to_run(it->value);
}
if (auto id = element.get_attribute(HTML::AttributeNames::id); !id.is_null()) {
if (auto it = rule_cache.rules_by_id.find(FlyString::from_utf8(id).release_value_but_fixme_should_propagate_errors()); it != rule_cache.rules_by_id.end())
if (auto it = rule_cache.rules_by_id.find(FlyString::from_deprecated_fly_string(id).release_value_but_fixme_should_propagate_errors()); it != rule_cache.rules_by_id.end())
add_rules_to_run(it->value);
}
if (auto it = rule_cache.rules_by_tag_name.find(FlyString::from_utf8(element.local_name()).release_value_but_fixme_should_propagate_errors()); it != rule_cache.rules_by_tag_name.end())
if (auto it = rule_cache.rules_by_tag_name.find(FlyString::from_deprecated_fly_string(element.local_name()).release_value_but_fixme_should_propagate_errors()); it != rule_cache.rules_by_tag_name.end())
add_rules_to_run(it->value);
add_rules_to_run(rule_cache.other_rules);
@ -699,7 +699,7 @@ bool StyleComputer::expand_unresolved_values(DOM::Element& element, StringView p
// 1. If the attr() function has a substitution value, replace the attr() function by the substitution value.
if (!attr_value.is_null()) {
// FIXME: attr() should also accept an optional type argument, not just strings.
dest.empend(Parser::Token::of_string(FlyString::from_utf8(attr_value).release_value_but_fixme_should_propagate_errors()));
dest.empend(Parser::Token::of_string(FlyString::from_deprecated_fly_string(attr_value).release_value_but_fixme_should_propagate_errors()));
continue;
}

View file

@ -528,7 +528,7 @@ static void paint_text_fragment(PaintContext& context, Layout::TextNode const& t
auto& font = fragment.layout_node().font();
auto scaled_font = [&]() -> RefPtr<Gfx::Font const> {
auto device_font_pt_size = context.enclosing_device_pixels(font.presentation_size());
FontSelector font_selector = { FlyString::from_utf8(font.family()).release_value_but_fixme_should_propagate_errors(), static_cast<float>(device_font_pt_size.value()), font.weight(), font.width(), font.slope() };
FontSelector font_selector = { FlyString::from_deprecated_fly_string(font.family()).release_value_but_fixme_should_propagate_errors(), static_cast<float>(device_font_pt_size.value()), font.weight(), font.width(), font.slope() };
if (auto cached_font = FontCache::the().get(font_selector)) {
return cached_font;
}