mirror of
https://github.com/lucko/LuckPerms.git
synced 2025-09-24 21:11:41 +02:00
Slightly optimize SimpleMetaValueSelector by only invoking the selection strategy if there is a selection to be made
This commit is contained in:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user