Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

Update Bank.sol #1510

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

ahmetmatematikci
Copy link

There are several things that can be optimized in this code. Firstly, the use of string type parameters can increase gas consumption. Therefore, lower gas-consuming types such as bytes32 or uint256 can be used as much as possible.

Secondly, mapping or array structures can be used instead of for loops, which can reduce gas consumption.

Thirdly, view functions can be preferred because they have lower gas consumption.

Fourthly, public functions can be used instead of external functions. external functions consume more gas because they make data copying when they are called.

Finally, correctly ordering the parameters of functions can reduce gas consumption. In particular, placing small parameters first can reduce gas consumption.

However, if there is no specific performance issue in this code, any optimization may be unnecessary.

There are several things that can be optimized in this code. Firstly, the use of `string` type parameters can increase gas consumption. Therefore, lower gas-consuming types such as `bytes32` or `uint256` can be used as much as possible.

Secondly, `mapping` or `array` structures can be used instead of `for` loops, which can reduce gas consumption.

Thirdly, `view` functions can be preferred because they have lower gas consumption.

Fourthly, `public` functions can be used instead of `external` functions. `external` functions consume more gas because they make data copying when they are called.

Finally, correctly ordering the parameters of functions can reduce gas consumption. In particular, placing small parameters first can reduce gas consumption.

However, if there is no specific performance issue in this code, any optimization may be unnecessary.

Signed-off-by: Ahmet KILIÇ <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant