mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 05:06:44 +01:00
perf: avoid quadratic overhead for UUID collection (#3749)
avoid quadratic overhead for UUID collection
This commit is contained in:
parent
e0eff15694
commit
3d19c5c2ad
@ -656,20 +656,15 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
final @NonNull SQLiteUUIDService sqLiteUUIDService,
|
final @NonNull SQLiteUUIDService sqLiteUUIDService,
|
||||||
final @NonNull CacheUUIDService cacheUUIDService
|
final @NonNull CacheUUIDService cacheUUIDService
|
||||||
) {
|
) {
|
||||||
// Load all uuids into a big chunky boi queue
|
// Record all unique UUID's and put them into a queue
|
||||||
final Queue<UUID> uuidQueue = new LinkedBlockingQueue<>();
|
final Set<UUID> uuidSet = new HashSet<>();
|
||||||
PlotSquared.get().forEachPlotRaw(plot -> {
|
PlotSquared.get().forEachPlotRaw(plot -> {
|
||||||
final Set<UUID> uuids = new HashSet<>();
|
uuidSet.add(plot.getOwnerAbs());
|
||||||
uuids.add(plot.getOwnerAbs());
|
uuidSet.addAll(plot.getMembers());
|
||||||
uuids.addAll(plot.getMembers());
|
uuidSet.addAll(plot.getTrusted());
|
||||||
uuids.addAll(plot.getTrusted());
|
uuidSet.addAll(plot.getDenied());
|
||||||
uuids.addAll(plot.getDenied());
|
|
||||||
for (final UUID uuid : uuids) {
|
|
||||||
if (!uuidQueue.contains(uuid)) {
|
|
||||||
uuidQueue.add(uuid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
final Queue<UUID> uuidQueue = new LinkedBlockingQueue<>(uuidSet);
|
||||||
|
|
||||||
LOGGER.info("(UUID) {} UUIDs will be cached", uuidQueue.size());
|
LOGGER.info("(UUID) {} UUIDs will be cached", uuidQueue.size());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user