changed the way we delete the empty slots to make it faster

git-svn-id: https://hyracks.googlecode.com/svn/branches/hyracks_indexes@422 123451ca-8445-de46-9d55-352943316053
diff --git a/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/impls/UnorderedSlotManager.java b/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/impls/UnorderedSlotManager.java
index 34155d4..631cfe6 100644
--- a/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/impls/UnorderedSlotManager.java
+++ b/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/impls/UnorderedSlotManager.java
@@ -80,17 +80,20 @@
 
     public void deleteEmptySlots() {
         int slotOff = getSlotStartOff();
-        int numOfSlots = ((getSlotStartOff() - getSlotEndOff()) / slotSize) + 1;
-        for (int i = 0; i < numOfSlots; i++) {
+        while (slotOff >= getSlotEndOff()) {
             if (frame.getBuffer().getInt(slotOff) == -1) {
-                int slotStartOff = getSlotEndOff();
-                int length = slotOff - slotStartOff;
-                System.arraycopy(frame.getBuffer().array(), slotStartOff, frame.getBuffer().array(), slotStartOff
-                        + slotSize, length);
-                ((NSMRTreeFrame) frame).setTupleCount(frame.getTupleCount() - 1);
-            } else {
-                slotOff -= slotSize;
+                while (frame.getBuffer().getInt(getSlotEndOff()) == -1) {
+                    ((NSMRTreeFrame) frame).setTupleCount(frame.getTupleCount() - 1);
+                }
+                if (slotOff > getSlotEndOff()) {
+                    System.arraycopy(frame.getBuffer().array(), getSlotEndOff(), frame.getBuffer().array(), slotOff,
+                            slotSize);
+                    ((NSMRTreeFrame) frame).setTupleCount(frame.getTupleCount() - 1);
+                } else {
+                    break;
+                }
             }
+            slotOff -= slotSize;
         }
     }
 }