Ignore:
Timestamp:
2014-02-07T01:34:02+01:00 (10 years ago)
Author:
bastiK
Message:

#8902 Small performance enhancements / coding style (patch by shinigami, parts)

patterns.diff: precompiled patterns
(only those parts applied, where performance may be relevant)

File:
1 edited

Legend:

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

    r6317 r6823  
    1616import java.util.Map.Entry;
    1717import java.util.Set;
     18import java.util.regex.Pattern;
     19
    1820import org.openstreetmap.josm.tools.Utils;
    1921
    2022/**
    2123 * TagCollection is a collection of tags which can be used to manipulate
    22  * tags managed by {@link OsmPrimitive}s.
     24 * tags managed by {@link org.openstreetmap.josm.data.osm.OsmPrimitive}s.
    2325 *
    2426 * A TagCollection can be created:
    2527 * <ul>
    26  *  <li>from the tags managed by a specific {@link OsmPrimitive} with {@link #from(Tagged)}</li>
    27  *  <li>from the union of all tags managed by a collection of {@link OsmPrimitive}s with {@link #unionOfAllPrimitives(Collection)}</li>
    28  *  <li>from the union of all tags managed by a {@link DataSet} with {@link #unionOfAllPrimitives(DataSet)}</li>
    29  *  <li>from the intersection of all tags managed by a collection of primitives with {@link #commonToAllPrimitives(Collection)}</li>
     28 *  <li>from the tags managed by a specific {@link org.openstreetmap.josm.data.osm.OsmPrimitive} with {@link #from(org.openstreetmap.josm.data.osm.Tagged)}</li>
     29 *  <li>from the union of all tags managed by a collection of {@link org.openstreetmap.josm.data.osm.OsmPrimitive}s with {@link #unionOfAllPrimitives(java.util.Collection)}</li>
     30 *  <li>from the union of all tags managed by a {@link org.openstreetmap.josm.data.osm.DataSet} with {@link #unionOfAllPrimitives(org.openstreetmap.josm.data.osm.DataSet)}</li>
     31 *  <li>from the intersection of all tags managed by a collection of primitives with {@link #commonToAllPrimitives(java.util.Collection)}</li>
    3032 * </ul>
    3133 *
     
    3335 *
    3436 * Basic set operations allow to create the union, the intersection and  the difference
    35  * of tag collections, see {@link #union(TagCollection)}, {@link #intersect(TagCollection)},
    36  * and {@link #minus(TagCollection)}.
     37 * of tag collections, see {@link #union(org.openstreetmap.josm.data.osm.TagCollection)}, {@link #intersect(org.openstreetmap.josm.data.osm.TagCollection)},
     38 * and {@link #minus(org.openstreetmap.josm.data.osm.TagCollection)}.
    3739 *
    3840 *
     
    4244    /**
    4345     * Creates a tag collection from the tags managed by a specific
    44      * {@link OsmPrimitive}. If <code>primitive</code> is null, replies
     46     * {@link org.openstreetmap.josm.data.osm.OsmPrimitive}. If <code>primitive</code> is null, replies
    4547     * an empty tag collection.
    4648     *
    4749     * @param primitive  the primitive
    4850     * @return a tag collection with the tags managed by a specific
    49      * {@link OsmPrimitive}
     51     * {@link org.openstreetmap.josm.data.osm.OsmPrimitive}
    5052     */
    5153    public static TagCollection from(Tagged primitive) {
     
    590592
    591593    /**
    592      * Applies this tag collection to an {@link OsmPrimitive}. Does nothing if
     594     * Applies this tag collection to an {@link org.openstreetmap.josm.data.osm.OsmPrimitive}. Does nothing if
    593595     * primitive is null
    594596     *
     
    611613
    612614    /**
    613      * Applies this tag collection to a collection of {@link OsmPrimitive}s. Does nothing if
     615     * Applies this tag collection to a collection of {@link org.openstreetmap.josm.data.osm.OsmPrimitive}s. Does nothing if
    614616     * primitives is null
    615617     *
     
    628630
    629631    /**
    630      * Replaces the tags of an {@link OsmPrimitive} by the tags in this collection . Does nothing if
     632     * Replaces the tags of an {@link org.openstreetmap.josm.data.osm.OsmPrimitive} by the tags in this collection . Does nothing if
    631633     * primitive is null
    632634     *
     
    646648
    647649    /**
    648      * Replaces the tags of a collection of{@link OsmPrimitive}s by the tags in this collection.
     650     * Replaces the tags of a collection of{@link org.openstreetmap.josm.data.osm.OsmPrimitive}s by the tags in this collection.
    649651     * Does nothing if primitives is null
    650652     *
     
    716718    }
    717719
     720    private static final Pattern SPLIT_VALUES_PATTERN = Pattern.compile(";\\s*");
     721
    718722    /**
    719723     * Replies the concatenation of all tag values (concatenated by a semicolon)
     
    732736        Map<String, Collection<String>> originalSplitValues = new LinkedHashMap<String, Collection<String>>();
    733737        for (String v : originalValues) {
    734             List<String> vs = Arrays.asList(v.split(";\\s*"));
     738            List<String> vs = Arrays.asList(SPLIT_VALUES_PATTERN.split(v));
    735739            originalSplitValues.put(v, vs);
    736740            values.addAll(vs);
Note: See TracChangeset for help on using the changeset viewer.