Comments (7)
the issue referenced mentions that memory is cheaper if you access more than once, but if you're accessing more than once, you should be using a stack variable anyway. I'll try to come up with some test cases to tease out when it make sense to use one vs the other
from 4naly3er.
@IllIllI000 I think that your results are spot on, memory
only makes sense for types smaller than the word.
I've tried doing some benchmarks myself and for arrays of uint256 calldata was always cheaper no matter how many times the array was accessed, and for uint248 or smaller memory was always cheaper. It's also true for bytes
, they are marginally cheaper as calldata. Out of curiosity I've tried uint256[][], and still calldata is cheaper.
from 4naly3er.
@IllIllI000 I am definitely interested in such test cases
from 4naly3er.
please remind me after March 25th (GMX contest end)
from 4naly3er.
⏰ it's after March 25th (sorry was reading the issues and maybe you still want to be reminded lol)
from 4naly3er.
Ah, thanks I did indeed forget. Still busy with other work, but won't submit this finding again until I have it worked out
from 4naly3er.
@CodeSandwich do you have an example where memory
is cheaper than calldata
when the array isn't an array where each array value is smaller than a word? That's the only type of scenario for which I was able to reproduce it: https://gist.github.com/IllIllI000/2ac9a647be917f58ffe5baa2cecbbc42
from 4naly3er.
Related Issues (11)
- `cacheVariable` sometimes is triggered for immutable variables HOT 1
- getting this error while running the 4nalyzer HOT 8
- Got this error on any of foundry repository
- Help needed HOT 1
- First link of issue is always link to second file. HOT 1
- Is it possible to specify remappings? HOT 1
- Consider Adding "hacktoberfest" Topic to Repository for Increased Visibility
- `delegateCallInLoop.ts` often ends up in an infinite loop HOT 1
- Cannot read file with 0 in the file name. HOT 1
- TypeError: Cannot read property 'contents' of undefined, TypeError: Cannot read property 'includes' of undefined HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from 4naly3er.