Changeset 8388 in josm


Ignore:
Timestamp:
2015-05-17T17:52:15+02:00 (6 years ago)
Author:
Don-vip
Message:

performance - use of EnumMap / EnumSet

Location:
trunk/src/org/openstreetmap/josm
Files:
13 edited

Legend:

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

    r8338 r8388  
    1010import java.util.ArrayList;
    1111import java.util.Collection;
    12 import java.util.HashMap;
     12import java.util.EnumMap;
    1313import java.util.List;
    1414import java.util.Map;
     
    119119
    120120        protected Map<OsmPrimitiveType, Integer> getSourceStatistics() {
    121             Map<OsmPrimitiveType, Integer> ret = new HashMap<>();
     121            Map<OsmPrimitiveType, Integer> ret = new EnumMap<>(OsmPrimitiveType.class);
    122122            for (OsmPrimitiveType type: OsmPrimitiveType.dataValues()) {
    123123                if (!getSourceTagsByType(type).isEmpty()) {
     
    129129
    130130        protected Map<OsmPrimitiveType, Integer> getTargetStatistics() {
    131             Map<OsmPrimitiveType, Integer> ret = new HashMap<>();
     131            Map<OsmPrimitiveType, Integer> ret = new EnumMap<>(OsmPrimitiveType.class);
    132132            for (OsmPrimitiveType type: OsmPrimitiveType.dataValues()) {
    133133                int count = OsmPrimitive.getFilteredList(target, type.getOsmClass()).size();
  • trunk/src/org/openstreetmap/josm/command/DeleteCommand.java

    r8376 r8388  
    1010import java.util.Collection;
    1111import java.util.Collections;
     12import java.util.EnumSet;
    1213import java.util.HashMap;
    1314import java.util.HashSet;
     
    157158
    158159    private Set<OsmPrimitiveType> getTypesToDelete() {
    159         Set<OsmPrimitiveType> typesToDelete = new HashSet<>();
     160        Set<OsmPrimitiveType> typesToDelete = EnumSet.noneOf(OsmPrimitiveType.class);
    160161        for (OsmPrimitive osm : toDelete) {
    161162            typesToDelete.add(OsmPrimitiveType.from(osm));
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r8387 r8388  
    3131import java.util.Arrays;
    3232import java.util.Collection;
    33 import java.util.HashMap;
     33import java.util.EnumMap;
    3434import java.util.LinkedList;
    3535import java.util.List;
     
    227227
    228228        public static Map<Option, Collection<String>> fromStringMap(Map<String, Collection<String>> opts) {
    229             Map<Option, Collection<String>> res = new HashMap<>();
     229            Map<Option, Collection<String>> res = new EnumMap<>(Option.class);
    230230            for (Map.Entry<String, Collection<String>> e : opts.entrySet()) {
    231231                Option o = Option.valueOf(e.getKey().toUpperCase().replace("-", "_"));
     
    247247        Getopt g = new Getopt("JOSM", args, "hv", los.toArray(new LongOpt[los.size()]));
    248248
    249         Map<Option, Collection<String>> argMap = new HashMap<>();
     249        Map<Option, Collection<String>> argMap = new EnumMap<>(Option.class);
    250250
    251251        int c;
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/ListMergeModel.java

    r8379 r8388  
    1313import java.beans.PropertyChangeListener;
    1414import java.util.ArrayList;
    15 import java.util.HashMap;
     15import java.util.EnumMap;
    1616import java.util.List;
    1717import java.util.Map;
     
    182182    }
    183183
     184    /**
     185     * Constructs a new {@code ListMergeModel}.
     186     */
    184187    public ListMergeModel() {
    185         entries = new HashMap<>();
     188        entries = new EnumMap<>(ListRole.class);
    186189        for (ListRole role : ListRole.values()) {
    187190            entries.put(role, new ArrayList<T>());
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/PasteTagsConflictResolverDialog.java

    r8332 r8388  
    1717import java.beans.PropertyChangeListener;
    1818import java.util.ArrayList;
     19import java.util.EnumMap;
    1920import java.util.HashMap;
    2021import java.util.List;
     
    4647    private static final Map<OsmPrimitiveType, String> PANE_TITLES;
    4748    static {
    48         PANE_TITLES = new HashMap<>();
     49        PANE_TITLES = new EnumMap<>(OsmPrimitiveType.class);
    4950        PANE_TITLES.put(OsmPrimitiveType.NODE, tr("Tags from nodes"));
    5051        PANE_TITLES.put(OsmPrimitiveType.WAY, tr("Tags from ways"));
     
    8283        setTitle(tr("Conflicts in pasted tags"));
    8384        allPrimitivesResolver = new TagConflictResolver();
    84         resolvers = new HashMap<>();
     85        resolvers = new EnumMap<>(OsmPrimitiveType.class);
    8586        for (OsmPrimitiveType type: OsmPrimitiveType.dataValues()) {
    8687            resolvers.put(type, new TagConflictResolver());
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/query/BasicChangesetQueryPanel.java

    r8308 r8388  
    1010import java.awt.event.ItemEvent;
    1111import java.awt.event.ItemListener;
    12 import java.util.HashMap;
     12import java.util.EnumMap;
    1313import java.util.Map;
    1414
     
    4949
    5050        ButtonGroup bgQueries = new ButtonGroup();
    51         rbQueries = new HashMap<>();
    52         lblQueries = new HashMap<>();
     51        rbQueries = new EnumMap<>(BasicQuery.class);
     52        lblQueries = new EnumMap<>(BasicQuery.class);
    5353        SelectQueryHandler selectedQueryHandler = new SelectQueryHandler();
    5454        for (BasicQuery q: BasicQuery.values()) {
  • trunk/src/org/openstreetmap/josm/gui/dialogs/validator/ValidatorTreePanel.java

    r8380 r8388  
    88import java.util.ArrayList;
    99import java.util.Collections;
     10import java.util.EnumMap;
    1011import java.util.Enumeration;
    1112import java.util.HashMap;
     
    173174        }
    174175
    175         Map<Severity, MultiMap<String, TestError>> errorTree = new HashMap<>();
    176         Map<Severity, HashMap<String, MultiMap<String, TestError>>> errorTreeDeep = new HashMap<>();
     176        Map<Severity, MultiMap<String, TestError>> errorTree = new EnumMap<>(Severity.class);
     177        Map<Severity, HashMap<String, MultiMap<String, TestError>>> errorTreeDeep = new EnumMap<>(Severity.class);
    177178        for (Severity s : Severity.values()) {
    178179            errorTree.put(s, new MultiMap<String, TestError>(20));
  • trunk/src/org/openstreetmap/josm/gui/history/RelationMemberListTableCellRenderer.java

    r8308 r8388  
    66import java.awt.Color;
    77import java.awt.Component;
    8 import java.util.HashMap;
     8import java.util.EnumMap;
    99import java.util.Map;
    1010
     
    2020
    2121/**
    22  * The {@link TableCellRenderer} for a list of relation members in {@link HistoryBrowser}
    23  *
    24  *
     22 * The {@link TableCellRenderer} for a list of relation members in {@link HistoryBrowser}.
     23 * @since 1709
    2524 */
    2625public class RelationMemberListTableCellRenderer extends JLabel implements TableCellRenderer {
     
    3837    public RelationMemberListTableCellRenderer() {
    3938        setOpaque(true);
    40         icons = new HashMap<>();
     39        icons = new EnumMap<>(OsmPrimitiveType.class);
    4140        icons.put(OsmPrimitiveType.NODE, ImageProvider.get("data", "node"));
    4241        icons.put(OsmPrimitiveType.WAY, ImageProvider.get("data", "way"));
  • trunk/src/org/openstreetmap/josm/gui/io/UploadStrategySelectionPanel.java

    r8375 r8388  
    1818import java.beans.PropertyChangeEvent;
    1919import java.beans.PropertyChangeListener;
    20 import java.util.HashMap;
     20import java.util.EnumMap;
    2121import java.util.Map;
    2222import java.util.Map.Entry;
     
    7474        pnl.setLayout(new GridBagLayout());
    7575        ButtonGroup bgStrategies = new ButtonGroup();
    76         rbStrategy = new HashMap<>();
    77         lblStrategies = new HashMap<>();
    78         lblNumRequests = new HashMap<>();
     76        rbStrategy = new EnumMap<>(UploadStrategy.class);
     77        lblStrategies = new EnumMap<>(UploadStrategy.class);
     78        lblNumRequests = new EnumMap<>(UploadStrategy.class);
    7979        for (UploadStrategy strategy: UploadStrategy.values()) {
    8080            rbStrategy.put(strategy, new JRadioButton());
  • trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginUpdatePolicyPanel.java

    r8308 r8388  
    88import java.awt.GridBagLayout;
    99import java.awt.Insets;
    10 import java.util.HashMap;
     10import java.util.EnumMap;
    1111import java.util.Map;
    1212
     
    6868
    6969        ButtonGroup bgVersionBasedUpdatePolicy = new ButtonGroup();
    70         rbVersionBasedUpatePolicy = new HashMap<>();
     70        rbVersionBasedUpatePolicy = new EnumMap<>(Policy.class);
    7171        JRadioButton btn = new JRadioButton(tr("Ask before updating"));
    7272        rbVersionBasedUpatePolicy.put(Policy.ASK, btn);
     
    109109
    110110        ButtonGroup bgTimeBasedUpdatePolicy = new ButtonGroup();
    111         rbTimeBasedUpatePolicy = new HashMap<>();
     111        rbTimeBasedUpatePolicy = new EnumMap<>(Policy.class);
    112112        JRadioButton btn = new JRadioButton(tr("Ask before updating"));
    113113        btn.addChangeListener(changeListener);
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/ProxyPreferencesPanel.java

    r8308 r8388  
    1515import java.net.PasswordAuthentication;
    1616import java.net.ProxySelector;
    17 import java.util.HashMap;
     17import java.util.EnumMap;
    1818import java.util.Map;
    1919
     
    237237
    238238        ButtonGroup bgProxyPolicy = new ButtonGroup();
    239         rbProxyPolicy = new HashMap<>();
     239        rbProxyPolicy = new EnumMap<>(ProxyPolicy.class);
    240240        ProxyPolicyChangeListener policyChangeListener = new ProxyPolicyChangeListener();
    241241        for (ProxyPolicy pp: ProxyPolicy.values()) {
  • trunk/src/org/openstreetmap/josm/io/auth/AbstractCredentialsAgent.java

    r7937 r8388  
    55import java.net.Authenticator.RequestorType;
    66import java.net.PasswordAuthentication;
    7 import java.util.HashMap;
     7import java.util.EnumMap;
    88import java.util.Map;
    99
     
    1313public abstract class AbstractCredentialsAgent implements CredentialsAgent {
    1414
    15     protected Map<RequestorType, PasswordAuthentication> memoryCredentialsCache = new HashMap<>();
     15    protected Map<RequestorType, PasswordAuthentication> memoryCredentialsCache = new EnumMap<>(RequestorType.class);
    1616
    1717    @Override
  • trunk/src/org/openstreetmap/josm/io/auth/DefaultAuthenticator.java

    r8126 r8388  
    44import java.net.Authenticator;
    55import java.net.PasswordAuthentication;
    6 import java.util.HashMap;
     6import java.util.EnumMap;
    77import java.util.Map;
    88
     
    3333    }
    3434
    35     private final Map<RequestorType, Boolean> credentialsTried = new HashMap<>();
     35    private final Map<RequestorType, Boolean> credentialsTried = new EnumMap<>(RequestorType.class);
    3636    private boolean enabled = true;
    3737
Note: See TracChangeset for help on using the changeset viewer.