Skip to content

Commit 326c466

Browse files
committed
Use Arrays.sol
1 parent 2a1f503 commit 326c466

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

contracts/utils/structs/EnumerableSet.sol

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -502,11 +502,7 @@ library EnumerableSet {
502502
for (uint256 i = 0; i < len; ++i) {
503503
delete set._positions[set._values[i]];
504504
}
505-
// Replace when these are available in Arrays.sol
506-
string[] storage array = set._values;
507-
assembly ("memory-safe") {
508-
sstore(array.slot, 0)
509-
}
505+
Arrays.unsafeSetLength(set._values, 0);
510506
}
511507

512508
/**
@@ -626,11 +622,7 @@ library EnumerableSet {
626622
for (uint256 i = 0; i < len; ++i) {
627623
delete set._positions[set._values[i]];
628624
}
629-
// Replace when these are available in Arrays.sol
630-
bytes[] storage array = set._values;
631-
assembly ("memory-safe") {
632-
sstore(array.slot, 0)
633-
}
625+
Arrays.unsafeSetLength(set._values, 0);
634626
}
635627

636628
/**

scripts/generate/templates/EnumerableSet.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,11 +345,7 @@ function clear(${name} storage set) internal {
345345
for (uint256 i = 0; i < len; ++i) {
346346
delete set._positions[set._values[i]];
347347
}
348-
// Replace when these are available in Arrays.sol
349-
${value.type}[] storage array = set._values;
350-
assembly ("memory-safe") {
351-
sstore(array.slot, 0)
352-
}
348+
Arrays.unsafeSetLength(set._values, 0);
353349
}
354350
355351
/**

0 commit comments

Comments
 (0)