mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
AK: Skip UTF-8 validation inside URL parser
Since we're already building up a percent-encoded ASCII-only string in the internal parser buffer, there's no need to do a second UTF-8 validation pass before assigning each part of the parsed URL. This makes URL parsing signficantly faster.
This commit is contained in:
parent
f045a877b4
commit
75cecd19a5
Notes:
sideshowbarker
2024-07-17 03:35:24 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/75cecd19a5 Pull-request: https://github.com/SerenityOS/serenity/pull/22496 Reviewed-by: https://github.com/LucasChollet
1 changed files with 5 additions and 5 deletions
|
@ -891,7 +891,7 @@ URL URLParser::basic_parse(StringView raw_input, Optional<URL> const& base_url,
|
|||
}
|
||||
|
||||
// 2. Set url’s scheme to buffer.
|
||||
url->m_scheme = buffer.to_string().release_value_but_fixme_should_propagate_errors();
|
||||
url->m_scheme = buffer.to_string_without_validation();
|
||||
|
||||
// 3. If state override is given, then:
|
||||
if (state_override.has_value()) {
|
||||
|
@ -1554,7 +1554,7 @@ URL URLParser::basic_parse(StringView raw_input, Optional<URL> const& base_url,
|
|||
buffer.append(':');
|
||||
}
|
||||
// 2. Append buffer to url’s path.
|
||||
url->m_paths.append(buffer.to_string().release_value_but_fixme_should_propagate_errors());
|
||||
url->m_paths.append(buffer.to_string_without_validation());
|
||||
}
|
||||
|
||||
// 5. Set buffer to the empty string.
|
||||
|
@ -1592,7 +1592,7 @@ URL URLParser::basic_parse(StringView raw_input, Optional<URL> const& base_url,
|
|||
|
||||
// 1. If c is U+003F (?), then set url’s query to the empty string and state to query state.
|
||||
if (code_point == '?') {
|
||||
url->m_paths[0] = buffer.to_string().release_value_but_fixme_should_propagate_errors();
|
||||
url->m_paths[0] = buffer.to_string_without_validation();
|
||||
url->m_query = String {};
|
||||
buffer.clear();
|
||||
state = State::Query;
|
||||
|
@ -1600,7 +1600,7 @@ URL URLParser::basic_parse(StringView raw_input, Optional<URL> const& base_url,
|
|||
// 2. Otherwise, if c is U+0023 (#), then set url’s fragment to the empty string and state to fragment state.
|
||||
else if (code_point == '#') {
|
||||
// NOTE: This needs to be percent decoded since the member variables contain decoded data.
|
||||
url->m_paths[0] = buffer.to_string().release_value_but_fixme_should_propagate_errors();
|
||||
url->m_paths[0] = buffer.to_string_without_validation();
|
||||
url->m_fragment = String {};
|
||||
buffer.clear();
|
||||
state = State::Fragment;
|
||||
|
@ -1619,7 +1619,7 @@ URL URLParser::basic_parse(StringView raw_input, Optional<URL> const& base_url,
|
|||
if (code_point != end_of_file) {
|
||||
URL::append_percent_encoded_if_necessary(buffer, code_point, URL::PercentEncodeSet::C0Control);
|
||||
} else {
|
||||
url->m_paths[0] = buffer.to_string().release_value_but_fixme_should_propagate_errors();
|
||||
url->m_paths[0] = buffer.to_string_without_validation();
|
||||
buffer.clear();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue