From d5194725b7634fb12947dabf35fc58796180ba2e Mon Sep 17 00:00:00 2001 From: Reason Date: Sat, 13 Mar 2021 17:19:29 +0800 Subject: [PATCH] Add optimization for EnumerableSet (#2588) Co-authored-by: Reason --- contracts/utils/structs/EnumerableSet.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/utils/structs/EnumerableSet.sol b/contracts/utils/structs/EnumerableSet.sol index 637f1901d..6b0107219 100644 --- a/contracts/utils/structs/EnumerableSet.sol +++ b/contracts/utils/structs/EnumerableSet.sol @@ -89,7 +89,7 @@ library EnumerableSet { // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // 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 set._values.pop();