perf: replace memory with calldata

This commit is contained in:
cedoor
2022-02-03 10:13:41 +01:00
parent 45acf0d0f9
commit efecda4f30
5 changed files with 15 additions and 15 deletions

View File

@@ -97,8 +97,8 @@ contract Example {
function removeLeaf(
bytes32 _treeId,
uint256 _leaf,
uint256[] memory _proofSiblings,
uint8[] memory _proofPathIndices
uint256[] calldata _proofSiblings,
uint8[] calldata _proofPathIndices
) external {
require(trees[_treeId].depth != 0, "Example: tree does not exist");
@@ -112,7 +112,7 @@ contract Example {
### Creating an Hardhat task to deploy the contract
```ts
```typescript
import { poseidon_gencontract as poseidonContract } from "circomlibjs"
import { Contract } from "ethers"
import { task, types } from "hardhat/config"

View File

@@ -32,8 +32,8 @@ contract BinaryTreeTest {
function removeLeaf(
bytes32 _treeId,
uint256 _leaf,
uint256[] memory _proofSiblings,
uint8[] memory _proofPathIndices
uint256[] calldata _proofSiblings,
uint8[] calldata _proofPathIndices
) external {
require(trees[_treeId].depth != 0, "BinaryTreeTest: tree does not exist");

View File

@@ -76,8 +76,8 @@ library IncrementalBinaryTree {
function remove(
IncrementalTreeData storage self,
uint256 leaf,
uint256[] memory proofSiblings,
uint8[] memory proofPathIndices
uint256[] calldata proofSiblings,
uint8[] calldata proofPathIndices
) public {
require(verify(self, leaf, proofSiblings, proofPathIndices), "IncrementalBinaryTree: leaf is not part of the tree");
@@ -111,8 +111,8 @@ library IncrementalBinaryTree {
function verify(
IncrementalTreeData storage self,
uint256 leaf,
uint256[] memory proofSiblings,
uint8[] memory proofPathIndices
uint256[] calldata proofSiblings,
uint8[] calldata proofPathIndices
) private view returns (bool) {
require(leaf < SNARK_SCALAR_FIELD, "IncrementalBinaryTree: leaf must be < SNARK_SCALAR_FIELD");
require(

View File

@@ -86,8 +86,8 @@ library IncrementalQuinTree {
function remove(
IncrementalTreeData storage self,
uint256 leaf,
uint256[4][] memory proofSiblings,
uint8[] memory proofPathIndices
uint256[4][] calldata proofSiblings,
uint8[] calldata proofPathIndices
) public {
require(verify(self, leaf, proofSiblings, proofPathIndices), "IncrementalQuinTree: leaf is not part of the tree");
@@ -125,8 +125,8 @@ library IncrementalQuinTree {
function verify(
IncrementalTreeData storage self,
uint256 leaf,
uint256[4][] memory proofSiblings,
uint8[] memory proofPathIndices
uint256[4][] calldata proofSiblings,
uint8[] calldata proofPathIndices
) private view returns (bool) {
require(leaf < SNARK_SCALAR_FIELD, "IncrementalQuinTree: leaf must be < SNARK_SCALAR_FIELD");
require(

View File

@@ -32,8 +32,8 @@ contract QuinTreeTest {
function removeLeaf(
bytes32 _treeId,
uint256 _leaf,
uint256[4][] memory _proofSiblings,
uint8[] memory _proofPathIndices
uint256[4][] calldata _proofSiblings,
uint8[] calldata _proofPathIndices
) external {
require(trees[_treeId].depth != 0, "QuinTreeTest: tree does not exist");