Improve performance of canRead() in HttpMessageReader's
Use MimeType.WILDCARD_TYPE for faster String.equals(). Move cheaper checks to the front of the canRead implementations. See gh-30192
This commit is contained in:
committed by
rstoyanchev
parent
b23cc01cb7
commit
e77faf7484
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -268,7 +268,8 @@ public class MimeType implements Comparable<MimeType>, Serializable {
|
||||
* @return whether the subtype is a wildcard
|
||||
*/
|
||||
public boolean isWildcardSubtype() {
|
||||
return WILDCARD_TYPE.equals(getSubtype()) || getSubtype().startsWith("*+");
|
||||
String subtype = getSubtype();
|
||||
return WILDCARD_TYPE.equals(subtype) || subtype.startsWith("*+");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -181,7 +181,7 @@ public abstract class MimeTypeUtils {
|
||||
|
||||
static {
|
||||
// Not using "parseMimeType" to avoid static init cost
|
||||
ALL = new MimeType("*", "*");
|
||||
ALL = new MimeType(MimeType.WILDCARD_TYPE, MimeType.WILDCARD_TYPE);
|
||||
APPLICATION_GRAPHQL = new MimeType("application", "graphql+json");
|
||||
APPLICATION_JSON = new MimeType("application", "json");
|
||||
APPLICATION_OCTET_STREAM = new MimeType("application", "octet-stream");
|
||||
|
||||
Reference in New Issue
Block a user