mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2025-01-04 07:28:13 +01:00
Slightly optimize SimpleMetaValueSelector by only invoking the selection strategy if there is a selection to be made
This commit is contained in:
parent
4d7a6cb658
commit
37e09caac5
@ -43,7 +43,14 @@ public class SimpleMetaValueSelector implements MetaValueSelector {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull String selectValue(@NonNull String key, @NonNull List<String> values) {
|
public @NonNull String selectValue(@NonNull String key, @NonNull List<String> values) {
|
||||||
return this.strategies.getOrDefault(key, this.defaultStrategy).select(values);
|
switch (values.size()) {
|
||||||
|
case 0:
|
||||||
|
throw new IllegalArgumentException("values is empty");
|
||||||
|
case 1:
|
||||||
|
return values.get(0);
|
||||||
|
default:
|
||||||
|
return this.strategies.getOrDefault(key, this.defaultStrategy).select(values);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Strategy {
|
public enum Strategy {
|
||||||
|
Loading…
Reference in New Issue
Block a user