Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detector: Cache array length #664

Merged
merged 33 commits into from
Aug 19, 2024
Merged

Detector: Cache array length #664

merged 33 commits into from
Aug 19, 2024

Conversation

TilakMaddy
Copy link
Collaborator

@TilakMaddy TilakMaddy commented Aug 12, 2024

Severity: Low

Qualifications: All solc versions

Logic:
Scan every for loop. Look inside the condition for any references to the length property of a storage variable array. Gather all those storage variables.

Now, look inside the for loop (investigate with callgraph) completely and see if any of those storage variable arrays gathered above, are being mutated. If yes, then there is no scope for caching the length outside. Once you ensure none of those storage variables are being mutated capture the for loop as a potential optimization opportunity

@TilakMaddy TilakMaddy changed the title Detector: Cache array length Detector: Cache array length (can review) Aug 12, 2024
@TilakMaddy TilakMaddy changed the base branch from feature/extract-written-state-variables to dev August 12, 2024 11:57
@TilakMaddy TilakMaddy changed the title Detector: Cache array length (can review) Detector: Cache array length Aug 12, 2024
@TilakMaddy TilakMaddy marked this pull request as ready for review August 12, 2024 11:58
@alexroan alexroan merged commit 81f8af5 into dev Aug 19, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants