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

Optimizations for similar_variables.py #1945

Merged
merged 4 commits into from
Jun 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions slither/detectors/variables/similar_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,16 @@ def detect_sim(contract: Contract) -> Set[Tuple[LocalVariable, LocalVariable]]:

contract_var = contract.variables

all_var = set(all_var + contract_var)
all_var = list(set(all_var + contract_var))

ret = []
for v1 in all_var:
for v2 in all_var:
if v1.name.lower() != v2.name.lower():
# pylint: disable=consider-using-enumerate
for i in range(len(all_var)):
v1 = all_var[i]
_v1_name_lower = v1.name.lower()
for j in range(i, len(all_var)):
0xGusMcCrae marked this conversation as resolved.
Show resolved Hide resolved
v2 = all_var[j]
if _v1_name_lower != v2.name.lower():
if SimilarVarsDetection.similar(v1.name, v2.name):
if (v2, v1) not in ret:
ret.append((v1, v2))
Expand Down