Ignore:
Timestamp:
2016-11-28T21:18:55+01:00 (9 years ago)
Author:
simon04
Message:

Loop can be replaced with Collection.removeIf()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/Main.java

    r11284 r11339  
    10921092        if (listener == null) return;
    10931093        synchronized (Main.class) {
    1094             Iterator<WeakReference<ProjectionChangeListener>> it = listeners.iterator();
    1095             while (it.hasNext()) {
    1096                 WeakReference<ProjectionChangeListener> wr = it.next();
    1097                 // remove the listener - and any other listener which got garbage
    1098                 // collected in the meantime
    1099                 if (wr.get() == null || wr.get() == listener) {
    1100                     it.remove();
    1101                 }
    1102             }
     1094            // remove the listener - and any other listener which got garbage
     1095            // collected in the meantime
     1096            listeners.removeIf(wr -> wr.get() == null || wr.get() == listener);
    11031097        }
    11041098    }
     
    11561150        if (listener == null) return;
    11571151        synchronized (Main.class) {
    1158             Iterator<WeakReference<WindowSwitchListener>> it = windowSwitchListeners.iterator();
    1159             while (it.hasNext()) {
    1160                 WeakReference<WindowSwitchListener> wr = it.next();
    1161                 // remove the listener - and any other listener which got garbage
    1162                 // collected in the meantime
    1163                 if (wr.get() == null || wr.get() == listener) {
    1164                     it.remove();
    1165                 }
    1166             }
     1152            // remove the listener - and any other listener which got garbage
     1153            // collected in the meantime
     1154            windowSwitchListeners.removeIf(wr -> wr.get() == null || wr.get() == listener);
    11671155            if (windowSwitchListeners.isEmpty()) {
    11681156                MasterWindowListener.teardown();
Note: See TracChangeset for help on using the changeset viewer.