Ignore:
Timestamp:
2014-02-07T00:18:58+01:00 (10 years ago)
Author:
bastiK
Message:

see #8902 - Small performance enhancements / coding style (patch by shinigami)

primitives.diff: few optimizations around osm primitives

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java

    r6629 r6821  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.data.osm;
     3
     4import org.openstreetmap.josm.tools.Utils;
    35
    46import static org.openstreetmap.josm.tools.I18n.tr;
     
    701703    @Override
    702704    public String getLocalName() {
    703         String key = "name:" + Locale.getDefault().toString();
    704         if (get(key) != null)
    705             return get(key);
    706         key = "name:" + Locale.getDefault().getLanguage() + "_" + Locale.getDefault().getCountry();
    707         if (get(key) != null)
    708             return get(key);
    709         key = "name:" + Locale.getDefault().getLanguage();
    710         if (get(key) != null)
    711             return get(key);
     705        final Locale locale = Locale.getDefault();
     706        String key = "name:" + locale.toString();
     707        String val = get(key);
     708        if (val != null)
     709            return val;
     710
     711        final String language = locale.getLanguage();
     712        key = "name:" + language + "_" + locale.getCountry();
     713        val = get(key);
     714        if (val != null)
     715            return val;
     716
     717        key = "name:" + language;
     718        val = get(key);
     719        if (val != null)
     720            return val;
     721
    712722        return getName();
     723    }
     724
     725    /**
     726     * Tests whether this primitive contains a tag consisting of {@code key} and {@code values}.
     727     * @param key the key forming the tag.
     728     * @param value value forming the tag.
     729     * @return true iff primitive contains a tag consisting of {@code key} and {@code value}.
     730     */
     731    public boolean hasTag(String key, String value) {
     732        return Utils.equal(value, get(key));
    713733    }
    714734
Note: See TracChangeset for help on using the changeset viewer.