Update README.md

This commit is contained in:
bt3gl 2022-07-25 17:30:30 -07:00 committed by GitHub
parent ec2bf17b8e
commit 0bcfa9322b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -33,6 +33,16 @@ uint8 numberTwo;
uint256 bigNumber;
```
---
### Constant vs. Immutable variables
Constant values can sometimes be cheaper than immutable values:
1. For a constant variable, the expression assigned to it is copied to all the places where it is accessed and also re-evaluated each time, allowing local optimizations.
2. Immutable variables are evaluated once at construction time and their value is copied to all the places in the code where they are accessed. For these values, 32 bytes are reserved, even if they would fit in fewer bytes.
---
### Mappings are cheaper than Arrays