mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
small optimization: do not filter if map is empty, do not allocate condition - prefer to use old good "for" and allocate list for result only if need
This commit is contained in:
@@ -4,7 +4,6 @@ package com.intellij.util.messages.impl;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.util.ConcurrencyUtil;
|
||||
import com.intellij.util.EventDispatcher;
|
||||
@@ -333,15 +332,19 @@ public class MessageBusImpl implements MessageBus {
|
||||
}
|
||||
else {
|
||||
final Map<MessageBusImpl, Integer> map = asRoot().myWaitingBuses.get();
|
||||
if (map != null) {
|
||||
List<MessageBusImpl> buses = ContainerUtil.filter(map.keySet(), new Condition<MessageBusImpl>() {
|
||||
@Override
|
||||
public boolean value(MessageBusImpl bus) {
|
||||
return ensureAlive(map, bus);
|
||||
if (map != null && !map.isEmpty()) {
|
||||
List<MessageBusImpl> liveBuses = null;
|
||||
for (MessageBusImpl bus : map.keySet()) {
|
||||
if (ensureAlive(map, bus)) {
|
||||
if (liveBuses == null) {
|
||||
liveBuses = new SmartList<MessageBusImpl>();
|
||||
}
|
||||
liveBuses.add(bus);
|
||||
}
|
||||
});
|
||||
if (!buses.isEmpty()) {
|
||||
pumpWaitingBuses(buses);
|
||||
}
|
||||
|
||||
if (liveBuses != null) {
|
||||
pumpWaitingBuses(liveBuses);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user