Changeset 17101 in josm


Ignore:
Timestamp:
2020-10-07T20:01:13+02:00 (4 years ago)
Author:
simon04
Message:

fix #19752 - StyleCache.intern: use HashMap instead of Storage

Location:
trunk/src/org/openstreetmap/josm/gui/mappaint
Files:
2 edited

Legend:

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

    r16630 r17101  
    33
    44import java.util.Arrays;
     5import java.util.Map;
    56import java.util.Optional;
     7import java.util.concurrent.ConcurrentHashMap;
     8import java.util.function.Function;
    69
    7 import org.openstreetmap.josm.data.osm.Storage;
    810import org.openstreetmap.josm.tools.Pair;
    911
     
    1618
    1719    // TODO: clean up the intern pool from time to time (after purge or layer removal)
    18     private static final Storage<StyleCache> internPool = new Storage<>();
     20    private static final Map<StyleCache, StyleCache> internPool = new ConcurrentHashMap<>();
    1921
    2022    /**
     
    98100     */
    99101    private StyleCache intern() {
    100         return internPool.putUnique(this);
     102        return internPool.computeIfAbsent(this, Function.identity());
    101103    }
    102104
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java

    r17042 r17101  
    653653        public boolean matches(Environment env) {
    654654            CheckParameterUtil.ensureParameterNotNull(env, "env");
    655             for (Condition c : conds) {
     655            return conds.stream().allMatch(c -> {
    656656                try {
    657                     if (!c.applies(env)) return false;
     657                    return c.applies(env);
    658658                } catch (PatternSyntaxException e) {
    659659                    Logging.log(Logging.LEVEL_ERROR, "PatternSyntaxException while applying condition" + c + ':', e);
    660660                    return false;
    661661                }
    662             }
    663             return true;
     662            });
    664663        }
    665664
Note: See TracChangeset for help on using the changeset viewer.