Avoid unnecessary sorting
This commit is contained in:
committed by
Rossen Stoyanchev
parent
87230c4f1f
commit
2093e35f27
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -76,7 +76,9 @@ public final class ConsumesRequestCondition extends AbstractRequestCondition<Con
|
||||
*/
|
||||
public ConsumesRequestCondition(String[] consumes, String[] headers) {
|
||||
this.expressions = new ArrayList<>(parseExpressions(consumes, headers));
|
||||
Collections.sort(this.expressions);
|
||||
if (this.expressions.size() > 1) {
|
||||
Collections.sort(this.expressions);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -93,7 +93,9 @@ public final class ProducesRequestCondition extends AbstractRequestCondition<Pro
|
||||
*/
|
||||
public ProducesRequestCondition(String[] produces, String[] headers, RequestedContentTypeResolver resolver) {
|
||||
this.expressions = new ArrayList<>(parseExpressions(produces, headers));
|
||||
Collections.sort(this.expressions);
|
||||
if (this.expressions.size() > 1) {
|
||||
Collections.sort(this.expressions);
|
||||
}
|
||||
this.contentTypeResolver = resolver != null ? resolver : DEFAULT_CONTENT_TYPE_RESOLVER;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user