We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 921ac49 commit 0abf18fCopy full SHA for 0abf18f
.changeset/fluffy-countries-buy.md
@@ -0,0 +1,5 @@
1
+---
2
+'openzeppelin-solidity': minor
3
4
+
5
+`Arrays`: Optimize `findUpperBound` by removing redundant SLOAD.
contracts/utils/Arrays.sol
@@ -22,13 +22,13 @@ library Arrays {
22
* repeated elements.
23
*/
24
function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {
25
- if (array.length == 0) {
26
- return 0;
27
- }
28
-
29
uint256 low = 0;
30
uint256 high = array.length;
31
+ if (high == 0) {
+ return 0;
+ }
32
while (low < high) {
33
uint256 mid = Math.average(low, high);
34
0 commit comments