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.
|
||||
@@ -77,7 +77,9 @@ public final class ConsumesRequestCondition extends AbstractRequestCondition<Con
|
||||
*/
|
||||
public ConsumesRequestCondition(String[] consumes, @Nullable 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.
|
||||
@@ -97,7 +97,9 @@ public final class ProducesRequestCondition extends AbstractRequestCondition<Pro
|
||||
@Nullable ContentNegotiationManager manager) {
|
||||
|
||||
this.expressions = new ArrayList<>(parseExpressions(produces, headers));
|
||||
Collections.sort(this.expressions);
|
||||
if (this.expressions.size() > 1) {
|
||||
Collections.sort(this.expressions);
|
||||
}
|
||||
this.contentNegotiationManager = manager != null ? manager : DEFAULT_CONTENT_NEGOTIATION_MANAGER;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user