Index: /trunk/src/org/openstreetmap/josm/gui/mappaint/DividedScale.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/mappaint/DividedScale.java	(revision 10144)
+++ /trunk/src/org/openstreetmap/josm/gui/mappaint/DividedScale.java	(revision 10145)
@@ -118,5 +118,5 @@
      * @param upper upper bound
      */
-    protected void putImpl(T o, double lower, double upper) {
+    private void putImpl(T o, double lower, double upper) {
         int i = 0;
         while (bd.get(i) < lower) {
@@ -164,4 +164,8 @@
     }
 
+    /**
+     * Runs a consistency test.
+     * @throws AssertionError When an invariant is broken.
+     */
     public void consistencyTest() {
         if (bd.size() < 2) throw new AssertionError(bd);
Index: /trunk/src/org/openstreetmap/josm/gui/mappaint/StyleCache.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/mappaint/StyleCache.java	(revision 10144)
+++ /trunk/src/org/openstreetmap/josm/gui/mappaint/StyleCache.java	(revision 10145)
@@ -9,4 +9,6 @@
 /**
  * Caches styles for a single primitive.
+ * <p>
+ * This object is immutable.
  */
 public final class StyleCache {
@@ -31,4 +33,11 @@
     }
 
+    /**
+     * Creates a new copy of this style cache with a new entry added.
+     * @param o The style to cache.
+     * @param r The range the style is for.
+     * @param selected The style list we should use (selected/unselected)
+     * @return The new object.
+     */
     public StyleCache put(StyleElementList o, Range r, boolean selected) {
         StyleCache s = new StyleCache(this);
@@ -37,8 +46,7 @@
         DividedScale<StyleElementList> ds = s.states[idx];
         if (ds == null) {
-            ds = s.states[idx] = new DividedScale<>();
+            ds = new DividedScale<>();
         }
-        ds.putImpl(o, r.getLower(), r.getUpper());
-        ds.consistencyTest();
+        s.states[idx] = ds.put(o, r);
         s.intern();
         return s;
