mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-29 19:10:26 +00:00
LibWeb: Make ON_WHITESPACE less heavy in HTML tokenizer
Once we know that the current code point is an ASCII character, we can just check if it's one of the HTML whitespace characters. Before this patch, we were using the generic StringView::contains(u32) path that splats a code point into a StringBuilder and then searches for it with memmem(). This reduces time spent in the HTML tokenizer from 16% to 6% when loading the ECMA-262 spec.
This commit is contained in:
parent
b400a34984
commit
c79e8aab0a
Notes:
sideshowbarker
2024-07-17 09:47:09 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/c79e8aab0a
1 changed files with 1 additions and 1 deletions
|
@ -121,7 +121,7 @@ namespace Web::HTML {
|
|||
if (current_input_character.has_value() && is_ascii_hex_digit(current_input_character.value()))
|
||||
|
||||
#define ON_WHITESPACE \
|
||||
if (current_input_character.has_value() && is_ascii(current_input_character.value()) && "\t\n\f "sv.contains(current_input_character.value()))
|
||||
if (current_input_character.has_value() && is_ascii(*current_input_character) && first_is_one_of(static_cast<char>(*current_input_character), '\t', '\n', '\f', ' '))
|
||||
|
||||
#define ANYTHING_ELSE if (1)
|
||||
|
||||
|
|
Loading…
Reference in a new issue