cleanup: use bulk operation instead of iteration
This commit is contained in:
@@ -259,9 +259,7 @@ public class Server {
|
||||
try {
|
||||
List<Channel> channelz = new ArrayList<>();
|
||||
for (World world : this.getWorlds()) {
|
||||
for (Channel ch : world.getChannels()) {
|
||||
channelz.add(ch);
|
||||
}
|
||||
channelz.addAll(world.getChannels());
|
||||
}
|
||||
return channelz;
|
||||
} catch (NullPointerException npe) {
|
||||
|
||||
@@ -130,9 +130,7 @@ public final class Channel {
|
||||
acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MapleCodecFactory()));
|
||||
acceptor.bind(new InetSocketAddress(port));
|
||||
((SocketSessionConfig) acceptor.getSessionConfig()).setTcpNoDelay(true);
|
||||
for (MapleExpeditionType exped : MapleExpeditionType.values()) {
|
||||
expedType.add(exped);
|
||||
}
|
||||
expedType.addAll(Arrays.asList(MapleExpeditionType.values()));
|
||||
|
||||
if (Server.getInstance().isOnline()) { // postpone event loading to improve boot time... thanks Riizade, daronhudson for noticing slow startup times
|
||||
eventSM = new EventScriptManager(this, getEvents());
|
||||
|
||||
@@ -51,9 +51,7 @@ public final class UseOwlOfMinervaHandler extends AbstractMaplePacketHandler {
|
||||
Comparator<Pair<Integer, Integer>> comparator = (p1, p2) -> p2.getRight().compareTo(p1.getRight());
|
||||
|
||||
PriorityQueue<Pair<Integer, Integer>> queue = new PriorityQueue<>(Math.max(1, owlSearched.size()), comparator);
|
||||
for(Pair<Integer, Integer> p : owlSearched) {
|
||||
queue.add(p);
|
||||
}
|
||||
queue.addAll(owlSearched);
|
||||
|
||||
owlLeaderboards = new LinkedList<>();
|
||||
for(int i = 0; i < Math.min(owlSearched.size(), 10); i++) {
|
||||
|
||||
@@ -53,10 +53,8 @@ public abstract class BaseScheduler {
|
||||
// NOTE: practice EXTREME caution when adding external locks to the scheduler system, if you don't know what you're doing DON'T USE THIS.
|
||||
protected BaseScheduler(MonitoredLockType lockType, List<MonitoredReentrantLock> extLocks) {
|
||||
schedulerLock = MonitoredReentrantLockFactory.createLock(lockType, true);
|
||||
|
||||
for(MonitoredReentrantLock lock : extLocks) {
|
||||
externalLocks.add(lock);
|
||||
}
|
||||
|
||||
externalLocks.addAll(extLocks);
|
||||
}
|
||||
|
||||
protected void addListener(SchedulerListener listener) {
|
||||
|
||||
@@ -457,9 +457,7 @@ public class World {
|
||||
|
||||
private static List<Entry<Integer, SortedMap<Integer, MapleCharacter>>> getSortedAccountCharacterView(Map<Integer, SortedMap<Integer, MapleCharacter>> map) {
|
||||
List<Entry<Integer, SortedMap<Integer, MapleCharacter>>> list = new ArrayList<>(map.size());
|
||||
for(Entry<Integer, SortedMap<Integer, MapleCharacter>> e : map.entrySet()) {
|
||||
list.add(e);
|
||||
}
|
||||
list.addAll(map.entrySet());
|
||||
|
||||
list.sort((o1, o2) -> o1.getKey() - o2.getKey());
|
||||
|
||||
@@ -483,9 +481,7 @@ public class World {
|
||||
}
|
||||
|
||||
for (Entry<Integer, SortedMap<Integer, MapleCharacter>> e : getSortedAccountCharacterView(accChars)) {
|
||||
for (MapleCharacter chr : e.getValue().values()) {
|
||||
chrList.add(chr);
|
||||
}
|
||||
chrList.addAll(e.getValue().values());
|
||||
}
|
||||
|
||||
return chrList;
|
||||
@@ -1359,9 +1355,7 @@ public class World {
|
||||
Comparator<Pair<Integer, Integer>> comparator = (p1, p2) -> p2.getRight().compareTo(p1.getRight());
|
||||
|
||||
PriorityQueue<Pair<Integer, Integer>> queue = new PriorityQueue<>(Math.max(1, tabSellers.size()), comparator);
|
||||
for(Pair<Integer, Integer> p : tabSellers) {
|
||||
queue.add(p);
|
||||
}
|
||||
queue.addAll(tabSellers);
|
||||
|
||||
tabLeaderboards = new LinkedList<>();
|
||||
for(int i = 0; i < Math.min(tabSellers.size(), 5); i++) {
|
||||
@@ -1548,9 +1542,7 @@ public class World {
|
||||
List<MaplePlayerShop> psList = new ArrayList<>();
|
||||
activePlayerShopsLock.lock();
|
||||
try {
|
||||
for(MaplePlayerShop mps : activePlayerShops.values()) {
|
||||
psList.add(mps);
|
||||
}
|
||||
psList.addAll(activePlayerShops.values());
|
||||
|
||||
return psList;
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user