Unverified Commit 165e6f19 by William Morriss Committed by GitHub

EnumerableSet: Remove Boundary Check in _at (#2606)

* remove boundary check

* fix tests for EnumerableSet "index out of bound"

* Changelog

Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
parent 750a1765
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
## Unreleased ## Unreleased
* Enumerables: Improve gas cost of removal in `EnumerableSet` and `EnumerableMap`. * Enumerables: Improve gas cost of removal in `EnumerableSet` and `EnumerableMap`.
* Enumerables: Improve gas cost of lookup in `EnumerableSet` and `EnumerableMap`.
## Unreleased ## Unreleased
......
...@@ -127,7 +127,6 @@ library EnumerableSet { ...@@ -127,7 +127,6 @@ library EnumerableSet {
* - `index` must be strictly less than {length}. * - `index` must be strictly less than {length}.
*/ */
function _at(Set storage set, uint256 index) private view returns (bytes32) { function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index]; return set._values[index];
} }
......
...@@ -51,7 +51,7 @@ function shouldBehaveLikeSet (valueA, valueB, valueC) { ...@@ -51,7 +51,7 @@ function shouldBehaveLikeSet (valueA, valueB, valueC) {
describe('at', function () { describe('at', function () {
it('reverts when retrieving non-existent elements', async function () { it('reverts when retrieving non-existent elements', async function () {
await expectRevert(this.set.at(0), 'EnumerableSet: index out of bounds'); await expectRevert.unspecified(this.set.at(0));
}); });
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment