ladybird/Userland/Libraries/LibWeb/CSS/Parser
Andreas Kling dba6216caa LibWeb: Skip CSS tokenizer filtering when string has no '\r' or '\f'
When loading a canned version of reddit.com, we end up parsing many many
shadow tree style sheets of roughly ~170 KiB text each.

None of them have '\r' or '\f', yet we spend 2-3 ms for each sheet just
looping over and reconstructing the text to see if we need to normalize
any newlines.

This patch makes the common case faster in two ways:

- We use TextCodec::Decoder::to_utf8() instead of process()
  This way, we do a one-shot fast validation and conversion to UTF-8,
  instead of using the generic code-point-at-a-time callback API.

- We scan for '\r' and '\f' before filtering, and if neither is present,
  we simply use the unfiltered string.

With these changes, we now spend 0 ms in the filtering function for the
vast majority of style sheets I've seen so far.
2024-07-20 15:35:30 +02:00
..
Block.cpp
Block.h
ComponentValue.cpp
ComponentValue.h
Declaration.cpp
Declaration.h
DeclarationOrAtRule.cpp
DeclarationOrAtRule.h
Dimension.h
Function.cpp
Function.h
GradientParsing.cpp LibWeb: Parse color values using TokenStream 2024-04-22 06:47:05 +02:00
Helpers.cpp AK+LibURL: Move AK::URL into a new URL library 2024-03-18 14:06:28 -04:00
MediaParsing.cpp LibWeb: Use parsing helpers in parse_media_feature_value() 2023-12-30 20:11:24 +01:00
Parser.cpp LibWeb/CSS: Make StringStyleValue hold a FlyString 2024-07-17 15:08:44 +01:00
Parser.h LibWeb/CSS: Support hwb, oklab and oklch color functions 2024-07-06 05:18:00 -06:00
ParsingContext.cpp LibWeb: Add CSS ParsingContext constructor with a realm and URL 2024-05-16 08:02:43 +02:00
ParsingContext.h LibWeb: Add CSS ParsingContext constructor with a realm and URL 2024-05-16 08:02:43 +02:00
Rule.cpp
Rule.h
SelectorParsing.cpp LibWeb: Implement the :has() pseudo-class 2024-07-15 11:52:03 +01:00
Token.cpp
Token.h
Tokenizer.cpp LibWeb: Skip CSS tokenizer filtering when string has no '\r' or '\f' 2024-07-20 15:35:30 +02:00
Tokenizer.h
TokenStream.h LibWeb: Allow creating a TokenStream from a single token 2023-12-30 20:11:24 +01:00