Ignore:
Timestamp:
2012-03-30T16:42:27+02:00 (12 years ago)
Author:
simon04
Message:

see #6964 - speedup presets initialization by some caching

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java

    r5050 r5136  
    10701070    }
    10711071
    1072     /**
    1073      * Called from the XML parser to set the types this preset affects
    1074      */
     1072    // 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)
     1073    private static final Map<String,EnumSet<PresetType>> typeCache =
     1074            new LinkedHashMap<String, EnumSet<PresetType>>(16, 1.1f, true);
    10751075
    10761076    static public EnumSet<PresetType> getType(String types) throws SAXException {
     1077        if (typeCache.containsKey(types)) {
     1078            return typeCache.get(types);
     1079        }
    10771080        EnumSet<PresetType> result = EnumSet.noneOf(PresetType.class);
    10781081        for (String type : Arrays.asList(types.split(","))) {
     
    10841087            }
    10851088        }
     1089        typeCache.put(types, result);
    10861090        return result;
    10871091    }
    10881092
     1093    /*
     1094     * Called from the XML parser to set the types this preset affects.
     1095     */
    10891096    public void setType(String types) throws SAXException {
    10901097        this.types = getType(types);
Note: See TracChangeset for help on using the changeset viewer.