1

Strangely, the execution cost of a function x() seems to sometimes increase with contract size (ie adding code to unrelated parts of the contract). To be clear, when adding the extra code to the contract, it does not affect the x() function. Is this supposed to happen? Why does it happen?

Unfortunately, I noticed this some time ago and don't have an example. I've seen others ask about it too.

0

If your function x() increases in complexity and if the function also makes changes to the state of the contract, such as updating values in state variables, then this increases the cost of gas. One way to help reduce the cost of execution is to try and store values in memory when possible.

  • Good tip about the memory. I'm wondering about the case where the function is not affected by the extra code at all. I've updated the question. – bevanb Oct 30 '17 at 19:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.