Browse Source

Add optimization for EnumerableSet (#2588)

Co-authored-by: Reason <Reason@Lee.com>
Reason 4 years ago
parent
commit
d5194725b7
1 changed files with 1 additions and 1 deletions
  1. 1 1
      contracts/utils/structs/EnumerableSet.sol

+ 1 - 1
contracts/utils/structs/EnumerableSet.sol

@@ -89,7 +89,7 @@ library EnumerableSet {
             // Move the last value to the index where the value to delete is
             // Move the last value to the index where the value to delete is
             set._values[toDeleteIndex] = lastvalue;
             set._values[toDeleteIndex] = lastvalue;
             // Update the index for the moved value
             // Update the index for the moved value
-            set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
+            set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex
 
 
             // Delete the slot where the moved value was stored
             // Delete the slot where the moved value was stored
             set._values.pop();
             set._values.pop();