mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibWeb: Do not copy the result of HeaderList::extract_header_list_values
There's no need to copy the Vector out of this result every time we call it. We can move it out or access it directly.
This commit is contained in:
parent
44fbf6451e
commit
ed27eea091
Notes:
github-actions[bot]
2025-11-26 14:16:24 +00:00
Author: https://github.com/trflynn89
Commit: ed27eea091
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6933
4 changed files with 45 additions and 39 deletions
|
|
@ -23,16 +23,17 @@ ReferrerPolicy parse_a_referrer_policy_from_a_referrer_policy_header(Fetch::Infr
|
|||
{
|
||||
// 1. Let policy-tokens be the result of extracting header list values given `Referrer-Policy` and response’s header list.
|
||||
auto policy_tokens_or_failure = response.header_list()->extract_header_list_values("Referrer-Policy"sv.bytes());
|
||||
auto policy_tokens = policy_tokens_or_failure.has<Vector<ByteBuffer>>() ? policy_tokens_or_failure.get<Vector<ByteBuffer>>() : Vector<ByteBuffer> {};
|
||||
|
||||
// 2. Let policy be the empty string.
|
||||
auto policy = ReferrerPolicy::EmptyString;
|
||||
|
||||
// 3. For each token in policy-tokens, if token is a referrer policy and token is not the empty string, then set policy to token.
|
||||
for (auto token : policy_tokens) {
|
||||
auto referrer_policy = from_string(token);
|
||||
if (referrer_policy.has_value() && referrer_policy.value() != ReferrerPolicy::EmptyString)
|
||||
policy = referrer_policy.release_value();
|
||||
if (auto const* policy_tokens = policy_tokens_or_failure.get_pointer<Vector<ByteBuffer>>()) {
|
||||
for (auto const& token : *policy_tokens) {
|
||||
auto referrer_policy = from_string(token);
|
||||
if (referrer_policy.has_value() && referrer_policy.value() != ReferrerPolicy::EmptyString)
|
||||
policy = referrer_policy.release_value();
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Return policy.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue