Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Vectorized committed Aug 28, 2023
1 parent 3e581db commit a9547a2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
24 changes: 12 additions & 12 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,11 @@ FixedPointMathLibTest:testSqrtHashedSingle() (gas: 53086)
FixedPointMathLibTest:testZeroFloorSub(uint256,uint256) (runs: 256, μ: 548, ~: 518)
FixedPointMathLibTest:testZeroFloorSubCasted(uint32,uint32,uint256) (runs: 256, μ: 905, ~: 945)
FixedPointMathLibTest:test__codesize() (gas: 19246)
JSONParserLibTest:testDecodeEncodedStringDoesNotRevert(string) (runs: 256, μ: 69740, ~: 60014)
JSONParserLibTest:testDecodeEncodedStringDoesNotRevert(string) (runs: 256, μ: 69045, ~: 59860)
JSONParserLibTest:testDecodeInvalidStringReverts() (gas: 159910)
JSONParserLibTest:testDecodeString() (gas: 181658)
JSONParserLibTest:testParseEmptyArrays() (gas: 626014)
JSONParserLibTest:testParseEmptyObjects() (gas: 626997)
JSONParserLibTest:testParseEmptyArrays() (gas: 625606)
JSONParserLibTest:testParseEmptyObjects() (gas: 626589)
JSONParserLibTest:testParseGas() (gas: 125792)
JSONParserLibTest:testParseInt() (gas: 166113)
JSONParserLibTest:testParseInvalidIntReverts() (gas: 194664)
Expand All @@ -385,17 +385,17 @@ JSONParserLibTest:testParseInvalidReverts() (gas: 8357030)
JSONParserLibTest:testParseInvalidStringReverts() (gas: 2018649)
JSONParserLibTest:testParseInvalidUintReverts() (gas: 290738)
JSONParserLibTest:testParseNumber() (gas: 839223)
JSONParserLibTest:testParseObject() (gas: 50521)
JSONParserLibTest:testParseRecursiveObject() (gas: 103486)
JSONParserLibTest:testParseSimpleArray() (gas: 24773)
JSONParserLibTest:testParseSimpleObject() (gas: 1641507)
JSONParserLibTest:testParseSimpleUintArray() (gas: 1240035)
JSONParserLibTest:testParseSpecials() (gas: 306895)
JSONParserLibTest:testParseObject() (gas: 50522)
JSONParserLibTest:testParseRecursiveObject() (gas: 103461)
JSONParserLibTest:testParseSimpleArray() (gas: 24768)
JSONParserLibTest:testParseSimpleObject() (gas: 1641255)
JSONParserLibTest:testParseSimpleUintArray() (gas: 1239783)
JSONParserLibTest:testParseSpecials() (gas: 306875)
JSONParserLibTest:testParseString() (gas: 1437072)
JSONParserLibTest:testParseUint() (gas: 87188)
JSONParserLibTest:testParseUint(uint256) (runs: 256, μ: 34087, ~: 27797)
JSONParserLibTest:testParseValidObjectDoesNotRevert(string,string) (runs: 256, μ: 61394, ~: 59425)
JSONParserLibTest:test__codesize() (gas: 34396)
JSONParserLibTest:testParseUint(uint256) (runs: 256, μ: 34156, ~: 27937)
JSONParserLibTest:testParseValidObjectDoesNotRevert(string,string) (runs: 256, μ: 61402, ~: 58152)
JSONParserLibTest:test__codesize() (gas: 34395)
LibBitTest:testAnd() (gas: 185677)
LibBitTest:testAnd(bool,bool) (runs: 256, μ: 668, ~: 667)
LibBitTest:testAutoClean(uint256,uint256) (runs: 256, μ: 446, ~: 446)
Expand Down
7 changes: 3 additions & 4 deletions src/utils/JSONParserLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -722,22 +722,21 @@ library JSONParserLib {
h_ := y_
o_ := add(o_, 0x20)
}
let w_ := not(0x1f)
let n_ := add(w_, sub(o_, _arr))
let n_ := sub(o_, add(_arr, 0x20))
mstore(_arr, shr(5, n_))
mstore(0x40, o_) // Allocate memory.
packed_ := setPointer(packed_, _BITPOS_CHILD, _arr)
mstore(item_, or(_BITMASK_CHILDREN_INITED, packed_))
// Reverse the array.
if iszero(lt(n_, 0x40)) {
let lo_ := add(_arr, 0x20)
let hi_ := add(_arr, n_)
let lo_ := add(_arr, 0x20)
for {} 1 {} {
let temp_ := mload(lo_)
mstore(lo_, mload(hi_))
mstore(hi_, temp_)
hi_ := add(hi_, w_)
lo_ := add(lo_, 0x20)
hi_ := sub(hi_, 0x20)
if iszero(lt(lo_, hi_)) { break }
}
}
Expand Down

0 comments on commit a9547a2

Please sign in to comment.