argotorg / argotorg/solidity

Optimize resizeDynamicArray

Open
#15,176 0 comments 0 reactions 0 assignees View on GitHub
bug :bug:
Dominant language
C++
Stars
25.7k
Forks
6.2k
Avg merge
2d 19h
Merged PRs (30d)
29

Description

## Description
https://github.com/ethereum/solidity/blob/cb1d21a9de839ce7c7a156f5364ac8877d7be41a/libsolidity/codegen/ArrayUtils.cpp#L642-L750
The two branches of the conditional jump at line 725 both pop the top elements, indicating that the top element is redundant. I noticed that the top element was introduced by the sload at line 672. It seems that this sloaded value is only used in the two branches of the conditional jump at line 679. Why not move this dup3 and sload before line 678?
Besides, I tried pushing and popping to a dynamic string array, using ```new``` to resize the dynamic array, and using ```sstore``` to set the length slot. None of these reached this function. After searching the whole program, I found that this function is not invoked anywhere. Is this function still in use? If not, why not delete it?

Contributor guide

Open the contributing guide

Research direction

Start in libsolidity/codegen/ArrayUtils.cpp at lines 642-750 and inspect the conditional branches around lines 672, 679, and 725. Search the program to determine whether resizeDynamicArray is still invoked; if it is, verify whether the sload and dup3 can be moved as described, and if not, determine whether the function can be removed.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, solidity
Domain
compilers
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.