- Timestamp:
- 2020-03-08T14:57:23+01:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/RecentTagCollection.java
r13992 r16080 4 4 import java.util.ArrayList; 5 5 import java.util.Iterator; 6 import java.util.LinkedHashMap;7 6 import java.util.List; 8 7 import java.util.Map; … … 13 12 import org.openstreetmap.josm.data.osm.search.SearchSetting; 14 13 import org.openstreetmap.josm.data.preferences.ListProperty; 14 import org.openstreetmap.josm.gui.util.LruCache; 15 15 import org.openstreetmap.josm.tools.Logging; 16 16 … … 19 19 */ 20 20 class RecentTagCollection { 21 22 /**23 * LRU cache for recently added tags (http://java-planet.blogspot.com/2005/08/how-to-set-up-simple-lru-cache-using.html)24 */25 static final class LruCache extends LinkedHashMap<Tag, Void> {26 private static final long serialVersionUID = 1L;27 private final int capacity;28 29 LruCache(int capacity) {30 super(capacity + 1, 1.1f, true);31 this.capacity = capacity;32 }33 34 @Override35 protected boolean removeEldestEntry(Map.Entry<Tag, Void> eldest) {36 return size() > capacity;37 }38 }39 21 40 22 private final Map<Tag, Void> recentTags; -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r15824 r16080 29 29 import java.util.HashMap; 30 30 import java.util.HashSet; 31 import java.util.LinkedHashMap;32 31 import java.util.List; 33 32 import java.util.Map; … … 119 118 import org.openstreetmap.josm.gui.progress.swing.PleaseWaitProgressMonitor; 120 119 import org.openstreetmap.josm.gui.util.GuiHelper; 120 import org.openstreetmap.josm.gui.util.LruCache; 121 121 import org.openstreetmap.josm.gui.widgets.FileChooserManager; 122 122 import org.openstreetmap.josm.gui.widgets.JosmTextArea; … … 182 182 183 183 /** List of recent relations */ 184 private final Map<Relation, Void> recentRelations = new LruCache (PROPERTY_RECENT_RELATIONS_NUMBER.get()+1);184 private final Map<Relation, Void> recentRelations = new LruCache<>(PROPERTY_RECENT_RELATIONS_NUMBER.get()); 185 185 186 186 /** … … 257 257 static String createLayerName(Object arg) { 258 258 return tr("Data Layer {0}", arg); 259 }260 261 static final class LruCache extends LinkedHashMap<Relation, Void> {262 private static final long serialVersionUID = 1L;263 LruCache(int initialCapacity) {264 super(initialCapacity, 1.1f, true);265 }266 267 @Override268 protected boolean removeEldestEntry(Map.Entry<Relation, Void> eldest) {269 return size() > PROPERTY_RECENT_RELATIONS_NUMBER.get();270 }271 259 } 272 260 -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetItem.java
r16042 r16080 9 9 import java.util.Collection; 10 10 import java.util.EnumSet; 11 import java.util.LinkedHashMap;12 11 import java.util.List; 13 12 import java.util.Map; … … 24 23 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList; 25 24 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionManager; 25 import org.openstreetmap.josm.gui.util.LruCache; 26 26 import org.openstreetmap.josm.spi.preferences.Config; 27 27 import org.openstreetmap.josm.tools.ImageProvider; … … 35 35 public abstract class TaggingPresetItem { 36 36 37 // cache the parsing of types using a LRU cache (http://java-planet.blogspot.com/2005/08/how-to-set-up-simple-lru-cache-using.html)38 private static final Map<String, Set<TaggingPresetType>> TYPE_CACHE = new L inkedHashMap<>(16, 1.1f, true);37 // cache the parsing of types using a LRU cache 38 private static final Map<String, Set<TaggingPresetType>> TYPE_CACHE = new LruCache<>(16);; 39 39 40 40 protected void initAutoCompletionField(AutoCompletingTextField field, String... key) { -
trunk/src/org/openstreetmap/josm/io/AbstractReader.java
r15820 r16080 42 42 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 43 43 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 44 import org.openstreetmap.josm.gui.util.LruCache; 44 45 import org.openstreetmap.josm.tools.CheckParameterUtil; 45 46 import org.openstreetmap.josm.tools.Logging; … … 421 422 } 422 423 424 private final Map<String, Integer> timestampCache = new LruCache<>(30); 425 423 426 protected final void parseTimestamp(PrimitiveData current, String time) { 424 427 if (time != null && !time.isEmpty()) { 425 current.setRawTimestamp((int) (DateUtils.tsFromString(time)/1000)); 428 int timestamp = timestampCache.computeIfAbsent(time, t -> (int) (DateUtils.tsFromString(t) / 1000)); 429 current.setRawTimestamp(timestamp); 426 430 } 427 431 }
Note:
See TracChangeset
for help on using the changeset viewer.