srctree

Robin Linden parent eaa47f33 68724fc8
css: Remove unnecessary allocations when expanding edge shorthands

inlinesplit
css/parser.cpp added: 7, removed: 6, total 1
@@ -436,7 +436,7 @@ std::optional<std::pair<std::string_view, std::string_view>> Parser::parse_decla
 
void Parser::add_declaration(Declarations &declarations, std::string_view name, std::string_view value) {
if (is_shorthand_edge_property(name)) {
expand_edge_values(declarations, std::string{name}, value);
expand_edge_values(declarations, name, value);
} else if (name == "background") {
expand_background(declarations, value);
} else if (name == "font") {
@@ -715,7 +715,8 @@ void Parser::expand_flex_flow(Declarations &declarations, std::string_view value
declarations.insert_or_assign(PropertyId::FlexWrap, std::move(wrap));
}
 
void Parser::expand_edge_values(Declarations &declarations, std::string property, std::string_view value) {
// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
void Parser::expand_edge_values(Declarations &declarations, std::string_view property, std::string_view value) {
std::string_view top, bottom, left, right;
Tokenizer tokenizer(value, ' ');
// NOLINTBEGIN(bugprone-unchecked-optional-access): False positives.
@@ -742,7 +743,7 @@ void Parser::expand_edge_values(Declarations &declarations, std::string property
break;
}
// NOLINTEND(bugprone-unchecked-optional-access)
std::string post_fix;
std::string_view post_fix;
if (property == "border-style") {
// border-style is a bit special as we want border-top-style instead of border-style-top-style.
property = "border";
 
css/parser.h added: 7, removed: 6, total 1
@@ -80,7 +80,7 @@ private:
// https://developer.mozilla.org/en-US/docs/Web/CSS/flex-flow
static void expand_flex_flow(Declarations &, std::string_view);
 
static void expand_edge_values(Declarations &, std::string property, std::string_view value);
static void expand_edge_values(Declarations &, std::string_view property, std::string_view value);
 
static void expand_font(Declarations &, std::string_view value);
};