LibWeb: Remove most of the copying of CSS::Parser::ComponentValue

This class was being copied all over the place, however, most of these
cases can be easily prevented with `auto const&` or `NonnullRawPtr<>`.

It also didn't have a move constructor, causing `Vector` to copy on
every resize as well.

Removing all these copies results in an almost 15% increase in
performance for CSS parsing, as measured with callgrind.
This commit is contained in:
Jonne Ransijn
2024-10-31 21:43:21 +01:00
committed by Sam Atkins
parent e50b9f5478
commit 0de9818470
5 changed files with 60 additions and 54 deletions

View File

@@ -121,7 +121,7 @@ NonnullRefPtr<MediaQuery> Parser::parse_media_query(TokenStream<ComponentValue>&
return media_query;
// `[ and <media-condition-without-or> ]?`
if (auto maybe_and = tokens.consume_a_token(); maybe_and.is_ident("and"sv)) {
if (auto const& maybe_and = tokens.consume_a_token(); maybe_and.is_ident("and"sv)) {
if (auto media_condition = parse_media_condition(tokens, MediaCondition::AllowOr::No)) {
tokens.discard_whitespace();
if (tokens.has_next_token())