Changeset 10145 in josm


Ignore:
Timestamp:
2016-04-15T09:42:16+02:00 (4 years ago)
Author:
bastiK
Message:

see #12598 - make DividedScale truely immutable (patch by michael2402)

Location:
trunk/src/org/openstreetmap/josm/gui/mappaint
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/DividedScale.java

    r9669 r10145  
    118118     * @param upper upper bound
    119119     */
    120     protected void putImpl(T o, double lower, double upper) {
     120    private void putImpl(T o, double lower, double upper) {
    121121        int i = 0;
    122122        while (bd.get(i) < lower) {
     
    164164    }
    165165
     166    /**
     167     * Runs a consistency test.
     168     * @throws AssertionError When an invariant is broken.
     169     */
    166170    public void consistencyTest() {
    167171        if (bd.size() < 2) throw new AssertionError(bd);
  • trunk/src/org/openstreetmap/josm/gui/mappaint/StyleCache.java

    r10000 r10145  
    99/**
    1010 * Caches styles for a single primitive.
     11 * <p>
     12 * This object is immutable.
    1113 */
    1214public final class StyleCache {
     
    3133    }
    3234
     35    /**
     36     * Creates a new copy of this style cache with a new entry added.
     37     * @param o The style to cache.
     38     * @param r The range the style is for.
     39     * @param selected The style list we should use (selected/unselected)
     40     * @return The new object.
     41     */
    3342    public StyleCache put(StyleElementList o, Range r, boolean selected) {
    3443        StyleCache s = new StyleCache(this);
     
    3746        DividedScale<StyleElementList> ds = s.states[idx];
    3847        if (ds == null) {
    39             ds = s.states[idx] = new DividedScale<>();
     48            ds = new DividedScale<>();
    4049        }
    41         ds.putImpl(o, r.getLower(), r.getUpper());
    42         ds.consistencyTest();
     50        s.states[idx] = ds.put(o, r);
    4351        s.intern();
    4452        return s;
Note: See TracChangeset for help on using the changeset viewer.