Swap header check in ReadOnlyHttp2Headers
Motivation: Pseudo headers are checked less frequently than normal headers, so it is more efficient to check the latter first. Modifications: Swap the order of the check, and fix minor formatting Result: Possibly more efficient header checks
This commit is contained in:
parent
e975c5f6fe
commit
9ba942e59b
@ -185,7 +185,7 @@ public class DefaultHttp2Headers
|
||||
|
||||
@Override
|
||||
public boolean contains(CharSequence name, CharSequence value, boolean caseInsensitive) {
|
||||
return contains(name, value, caseInsensitive? CASE_INSENSITIVE_HASHER : CASE_SENSITIVE_HASHER);
|
||||
return contains(name, value, caseInsensitive ? CASE_INSENSITIVE_HASHER : CASE_SENSITIVE_HASHER);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -774,11 +774,12 @@ public final class ReadOnlyHttp2Headers implements Http2Headers {
|
||||
@Override
|
||||
public boolean contains(CharSequence name, CharSequence value, boolean caseInsensitive) {
|
||||
final int nameHash = AsciiString.hashCode(name);
|
||||
final HashingStrategy<CharSequence> strategy = caseInsensitive? CASE_INSENSITIVE_HASHER : CASE_SENSITIVE_HASHER;
|
||||
final HashingStrategy<CharSequence> strategy =
|
||||
caseInsensitive ? CASE_INSENSITIVE_HASHER : CASE_SENSITIVE_HASHER;
|
||||
final int valueHash = strategy.hashCode(value);
|
||||
|
||||
return contains(name, nameHash, value, valueHash, strategy, pseudoHeaders)
|
||||
|| contains(name, nameHash, value, valueHash, strategy, otherHeaders);
|
||||
return contains(name, nameHash, value, valueHash, strategy, otherHeaders)
|
||||
|| contains(name, nameHash, value, valueHash, strategy, pseudoHeaders);
|
||||
}
|
||||
|
||||
private static boolean contains(CharSequence name, int nameHash, CharSequence value, int valueHash,
|
||||
|
Loading…
Reference in New Issue
Block a user