LibWeb: Stop allocating Tokens and ComponentValues unnecessarily

When the "Consume a component value from input, and do nothing."
step in `Parser::consume_the_remnants_of_a_bad_declaration` was
executed, it would allocate a `ComponentValue` that was then
immediately discarded.

Add explicitly `{}_and_do_nothing` functions for this case that never
allocate a `ComponentValue` in the first place.

Also remove a `(Token)` cast, which was unnecessarily copying a `Token`
as well.
This commit is contained in:
Jonne Ransijn 2024-11-30 18:31:04 +01:00 committed by Andreas Kling
commit 3f5e32ee84
Notes: github-actions[bot] 2024-12-01 10:31:01 +00:00
2 changed files with 132 additions and 7 deletions

View file

@ -161,9 +161,15 @@ private:
template<typename T>
[[nodiscard]] ComponentValue consume_a_component_value(TokenStream<T>&);
template<typename T>
void consume_a_component_value_and_do_nothing(TokenStream<T>&);
template<typename T>
SimpleBlock consume_a_simple_block(TokenStream<T>&);
template<typename T>
void consume_a_simple_block_and_do_nothing(TokenStream<T>&);
template<typename T>
Function consume_a_function(TokenStream<T>&);
template<typename T>
void consume_a_function_and_do_nothing(TokenStream<T>&);
// TODO: consume_a_unicode_range_value()
Optional<GeneralEnclosed> parse_general_enclosed(TokenStream<ComponentValue>&);