macrergate commented on code in PR #10045:
URL: https://github.com/apache/ignite/pull/10045#discussion_r883505993


##########
modules/core/src/main/java/org/apache/ignite/internal/util/GridHandleTable.java:
##########
@@ -107,6 +121,14 @@ public int lookup(Object obj) {
      * Resets table to its initial (empty) state.
      */
     public void clear() {
+        if (size < objs.length) {
+            if (shrink()) {
+                size = 0;
+
+                return;
+            }
+        }
+
         System.arraycopy(spineEmpty, 0, spine, 0, spineEmpty.length);
         System.arraycopy(nextEmpty, 0, next, 0, nextEmpty.length);

Review Comment:
   ```suggestion
           just some more thoughts: 
   -         I guess that the array 'next' can be not cleaned at all as we  are 
resetting 'size' to zero and we never read the next array elements with 
index>=size
   
   -       we could consider zero value as empty not -1, if we would change 
postitioning to 'int idx = (hash(obj) % spine.length) + 1; in this case  we 
wouldn't need to fill int arrays in init() method as they have zeroes by 
default.
           
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to