Ver Fonte

Use `Sets.newHashSetWithExpectedSize` (#125327)

IJ complains about the static method not being available -- I don't see
a reason against using the regular constructor here instead.
Nikolaj Volgushev há 7 meses atrás
pai
commit
abd2bdd70e

+ 3 - 2
x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/IndexPrivilege.java

@@ -34,6 +34,7 @@ import org.elasticsearch.action.search.TransportSearchShardsAction;
 import org.elasticsearch.action.support.IndexComponentSelector;
 import org.elasticsearch.cluster.metadata.DataStream;
 import org.elasticsearch.common.Strings;
+import org.elasticsearch.common.util.set.Sets;
 import org.elasticsearch.core.Nullable;
 import org.elasticsearch.index.seqno.RetentionLeaseActions;
 import org.elasticsearch.xpack.core.ccr.action.ForgetFollowerAction;
@@ -452,8 +453,8 @@ public final class IndexPrivilege extends Privilege {
         Collection<String> actions,
         IndexComponentSelectorPredicate selectorPredicate
     ) {
-        final Set<Automaton> automata = HashSet.newHashSet(privileges.size() + actions.size());
-        final Set<String> names = HashSet.newHashSet(privileges.size() + actions.size());
+        final Set<Automaton> automata = Sets.newHashSetWithExpectedSize(privileges.size() + actions.size());
+        final Set<String> names = Sets.newHashSetWithExpectedSize(privileges.size() + actions.size());
         for (IndexPrivilege privilege : privileges) {
             names.addAll(privilege.name());
             automata.add(privilege.automaton);