diff --git a/roaringbitmap/src/main/java/org/roaringbitmap/ContainerAppender.java b/roaringbitmap/src/main/java/org/roaringbitmap/ContainerAppender.java
index <HASH>..<HASH> 100644
--- a/roaringbitmap/src/main/java/org/roaringbitmap/ContainerAppender.java
+++ b/roaringbitmap/src/main/java/org/roaringbitmap/ContainerAppender.java
@@ -81,7 +81,10 @@ public class ContainerAppender<C extends WordStorage<C>,
         currentKey = key;
       }
     }
-    container = container.add(lowbits(value));
+    C tmp = container.add(lowbits(value));
+    if (tmp != container) {
+      container = tmp;
+    }
   }
 
   @Override
avoid potentially costly write barrier when container instance hasn't changed (#<I>)