improve speed of NodeTools#removeSamePermission
This commit is contained in:
parent
7bfd5d4bc8
commit
af8fd15929
@ -30,8 +30,10 @@ import lombok.experimental.UtilityClass;
|
|||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class NodeTools {
|
public class NodeTools {
|
||||||
@ -88,19 +90,14 @@ public class NodeTools {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static <T extends Node> void removeSamePermission(Iterator<T> it) {
|
public static <T extends Node> void removeSamePermission(Iterator<T> it) {
|
||||||
List<T> alreadyIn = new ArrayList<>();
|
Set<String> alreadyIn = new HashSet<>();
|
||||||
|
|
||||||
iter:
|
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
T next = it.next();
|
T next = it.next();
|
||||||
for (T n : alreadyIn) {
|
|
||||||
if (next.getPermission().equals(n.getPermission())) {
|
|
||||||
it.remove();
|
|
||||||
continue iter;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
alreadyIn.add(next);
|
if (!alreadyIn.add(next.getPermission())) {
|
||||||
|
it.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user