Ignore:
Timestamp:
2015-05-06T00:23:51+02:00 (4 years ago)
Author:
Don-vip
Message:

fix various issues:

  • performance - inefficient use of keySet iterator instead of entrySet iterator
  • squid:S2674: The value returned from a stream read should be checked
  • remove unused imports
  • improve javadoc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserDialogManager.java

    r8285 r8332  
    99import java.util.Collection;
    1010import java.util.HashMap;
     11import java.util.Iterator;
    1112import java.util.List;
    1213import java.util.Map;
     14import java.util.Map.Entry;
     15import java.util.Objects;
    1316
    1417import javax.swing.JOptionPane;
     
    105108     */
    106109    public void hide(HistoryBrowserDialog dialog) {
    107         long id = 0;
    108         for (long i: dialogs.keySet()) {
    109             if (dialogs.get(i) == dialog) {
    110                 id = i;
     110        for (Iterator<Entry<Long, HistoryBrowserDialog>> it = dialogs.entrySet().iterator(); it.hasNext(); ) {
     111            if (Objects.equals(it.next().getValue(), dialog)) {
     112                it.remove();
     113                if (dialogs.isEmpty()) {
     114                    new WindowGeometry(dialog).remember(WINDOW_GEOMETRY_PREF);
     115                }
    111116                break;
    112             }
    113         }
    114         if (id > 0) {
    115             dialogs.remove(id);
    116             if (dialogs.isEmpty()) {
    117                 new WindowGeometry(dialog).remember(WINDOW_GEOMETRY_PREF);
    118117            }
    119118        }
Note: See TracChangeset for help on using the changeset viewer.