Changeset 8141 in josm


Ignore:
Timestamp:
2015-03-15T19:19:06+01:00 (9 years ago)
Author:
bastiK
Message:

applied #11231 - MapCSS: Use PriorityQueue instead of sorting an ArrayList (patch by Michael Zangl)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java

    r8130 r8141  
    1313import java.text.MessageFormat;
    1414import java.util.ArrayList;
    15 import java.util.Collection;
    1615import java.util.Collections;
    1716import java.util.HashMap;
     
    2019import java.util.Map;
    2120import java.util.Map.Entry;
     21import java.util.PriorityQueue;
    2222import java.util.Set;
    2323import java.util.concurrent.locks.ReadWriteLock;
     
    137137        public final Map<String,Map<String,Set<MapCSSRule>>> index = new HashMap<>();
    138138        /* rules without SimpleKeyValueCondition */
    139         public final Set<MapCSSRule> remaining = new HashSet<>();
     139        public final ArrayList<MapCSSRule> remaining = new ArrayList<>();
    140140
    141141        public void add(MapCSSRule rule) {
     
    178178                rulesWithMatchingKeyValue.add(r);
    179179            }
     180            Collections.sort(remaining);
    180181        }
    181182
     
    188189         * You must have a read lock of STYLE_SOURCE_LOCK when calling this method.
    189190         */
    190         public Collection<MapCSSRule> getRuleCandidates(OsmPrimitive osm) {
    191             List<MapCSSRule> ruleCandidates = new ArrayList<>(remaining);
     191        public PriorityQueue<MapCSSRule> getRuleCandidates(OsmPrimitive osm) {
     192            PriorityQueue<MapCSSRule> ruleCandidates = new PriorityQueue<>(remaining);
    192193            for (Map.Entry<String,String> e : osm.getKeys().entrySet()) {
    193194                Map<String,Set<MapCSSRule>> v = index.get(e.getKey());
     
    199200                }
    200201            }
    201             Collections.sort(ruleCandidates);
    202202            return ruleCandidates;
    203203        }
     
    489489        int lastDeclUsed = -1;
    490490
    491         for (MapCSSRule r : matchingRuleIndex.getRuleCandidates(osm)) {
     491        PriorityQueue<MapCSSRule> candidates = matchingRuleIndex.getRuleCandidates(osm);
     492        MapCSSRule r;
     493        while ((r = candidates.poll()) != null) {
    492494            env.clearSelectorMatchingInformation();
    493495            env.layer = null;
Note: See TracChangeset for help on using the changeset viewer.