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
|
|
| 2 | 2 | package org.openstreetmap.josm.gui.mappaint; |
| 3 | 3 | |
| 4 | 4 | import java.util.Arrays; |
| | 5 | import java.util.HashMap; |
| 5 | 6 | import java.util.Optional; |
| | 7 | import java.util.function.Function; |
| 6 | 8 | |
| 7 | | import org.openstreetmap.josm.data.osm.Storage; |
| 8 | 9 | import org.openstreetmap.josm.tools.Pair; |
| 9 | 10 | |
| 10 | 11 | /** |
| … |
… |
|
| 15 | 16 | public final class StyleCache { |
| 16 | 17 | |
| 17 | 18 | // 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<>(); |
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * An empty style cache entry |
| … |
… |
public boolean equals(Object obj) {
|
| 97 | 98 | * @return style cache |
| 98 | 99 | */ |
| 99 | 100 | private StyleCache intern() { |
| 100 | | return internPool.putUnique(this); |
| | 101 | return internPool.computeIfAbsent(this, Function.identity()); |
| 101 | 102 | } |
| 102 | 103 | |
| 103 | 104 | /** |
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) {
|
| 649 | 649 | @Override |
| 650 | 650 | public boolean matches(Environment env) { |
| 651 | 651 | CheckParameterUtil.ensureParameterNotNull(env, "env"); |
| 652 | | for (Condition c : conds) { |
| | 652 | return conds.stream().allMatch(c -> { |
| 653 | 653 | try { |
| 654 | | if (!c.applies(env)) return false; |
| | 654 | return c.applies(env); |
| 655 | 655 | } catch (PatternSyntaxException e) { |
| 656 | 656 | Logging.log(Logging.LEVEL_ERROR, "PatternSyntaxException while applying condition" + c + ':', e); |
| 657 | 657 | return false; |
| 658 | 658 | } |
| 659 | | } |
| 660 | | return true; |
| | 659 | }); |
| 661 | 660 | } |
| 662 | 661 | |
| 663 | 662 | @Override |