mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-12-29 12:37:40 +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
|
||||
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 {
|
||||
|
Loading…
Reference in New Issue
Block a user