add some comments
diff --git a/src/main/java/org/apache/datasketches/memory/BaseState.java b/src/main/java/org/apache/datasketches/memory/BaseState.java
index 5375b10..0ff1c03 100644
--- a/src/main/java/org/apache/datasketches/memory/BaseState.java
+++ b/src/main/java/org/apache/datasketches/memory/BaseState.java
@@ -371,11 +371,17 @@
final void assertValidAndBoundsForRead(final long offsetBytes, final long lengthBytes) {
assertValid();
+ // capacityBytes_ is intentionally read directly instead of calling getCapacity()
+ // because the later can make JVM to not inline the assert code path (and entirely remove it)
+ // even though it does nothing in production code path.
assertBounds(offsetBytes, lengthBytes, capacityBytes_);
}
final void assertValidAndBoundsForWrite(final long offsetBytes, final long lengthBytes) {
assertValid();
+ // capacityBytes_ is intentionally read directly instead of calling getCapacity()
+ // because the later can make JVM to not inline the assert code path (and entirely remove it)
+ // even though it does nothing in production code path.
assertBounds(offsetBytes, lengthBytes, capacityBytes_);
assert !isReadOnly() : "Memory is read-only.";
}