stefanvodita commented on code in PR #12812:
URL: https://github.com/apache/lucene/pull/12812#discussion_r1420699163


##########
lucene/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java:
##########
@@ -179,6 +179,19 @@ static class SlicedIntBlockPool extends IntBlockPool {
       super(allocator);
     }
 
+    /**
+     * For slices, buffers must be filled with zeros, so that we can find a 
slice's end based on a
+     * non-zero final value.
+     */
+    private static boolean assertSliceBuffer(int[] buffer) {
+      for (int value : buffer) {

Review Comment:
   I think that’s possible, but I have some counterarguments:
   1. Branch prediction will kick in. We should never take the branch, so 
mispredictions will be rare and they will happen when we want to stop execution 
anyway.
   2. We would not enable assertions in performance-critical situations, so 
this method would not run at all.
   3. The previous solution has other problems. The count can overflow. It can 
also be zero at the end if it encounters negative and positive values along the 
way that happened to add up to zero.



##########
lucene/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java:
##########
@@ -179,6 +179,19 @@ static class SlicedIntBlockPool extends IntBlockPool {
       super(allocator);
     }
 
+    /**
+     * For slices, buffers must be filled with zeros, so that we can find a 
slice's end based on a
+     * non-zero final value.
+     */
+    private static boolean assertSliceBuffer(int[] buffer) {
+      for (int value : buffer) {

Review Comment:
   I think that’s possible, but I have some counterarguments:
   1. Branch prediction will kick in. We should never take the branch, so 
mispredictions will be rare and they will happen when we want to stop execution 
anyway.
   2. We would not enable assertions in performance-critical situations, so 
this method would not run at all.
   3. The previous solution has other problems. The count can overflow. It can 
also be zero at the end if it encounters negative and positive values along the 
way that happened to add up to zero.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to