Ticket #19752: 19752.patch

File 19752.patch, 2.4 KB (added by simon04, 5 years ago)
  • src/org/openstreetmap/josm/gui/mappaint/StyleCache.java

    commit a4ec9e0dd170f76af014fcaf61a6c1709cc5e3ff
    Author: Simon Legner <Simon.Legner@gmail.com>
    Date:   2020-09-02 22:59:11 +0200
    
        fix #19752 - StyleCache.intern: use HashMap instead of Storage
    
    diff --git a/src/org/openstreetmap/josm/gui/mappaint/StyleCache.java b/src/org/openstreetmap/josm/gui/mappaint/StyleCache.java
    index 0970b2e84..6bcfd0ce9 100644
    a b  
    22package org.openstreetmap.josm.gui.mappaint;
    33
    44import java.util.Arrays;
     5import java.util.HashMap;
    56import java.util.Optional;
     7import java.util.function.Function;
    68
    7 import org.openstreetmap.josm.data.osm.Storage;
    89import org.openstreetmap.josm.tools.Pair;
    910
    1011/**
     
    1516public final class StyleCache {
    1617
    1718    // TODO: clean up the intern pool from time to time (after purge or layer removal)
    18     private static final Storage<StyleCache> internPool = new Storage<>();
     19    private static final HashMap<StyleCache, StyleCache> internPool = new HashMap<>();
    1920
    2021    /**
    2122     * An empty style cache entry
    public boolean equals(Object obj) {  
    9798     * @return style cache
    9899     */
    99100    private StyleCache intern() {
    100         return internPool.putUnique(this);
     101        return internPool.computeIfAbsent(this, Function.identity());
    101102    }
    102103
    103104    /**
  • src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java

    diff --git a/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java b/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java
    index 40eb3f14a..a6ba97767 100644
    a b protected AbstractSelector(List<Condition> conditions) {  
    649649        @Override
    650650        public boolean matches(Environment env) {
    651651            CheckParameterUtil.ensureParameterNotNull(env, "env");
    652             for (Condition c : conds) {
     652            return conds.stream().allMatch(c -> {
    653653                try {
    654                     if (!c.applies(env)) return false;
     654                    return c.applies(env);
    655655                } catch (PatternSyntaxException e) {
    656656                    Logging.log(Logging.LEVEL_ERROR, "PatternSyntaxException while applying condition" + c + ':', e);
    657657                    return false;
    658658                }
    659             }
    660             return true;
     659            });
    661660        }
    662661
    663662        @Override