Merge pull request #1945 from 0xGusMcCrae/fast-sim-var

Optimizations for similar_variables.py
pull/1961/head
Feist Josselin 1 year ago committed by GitHub
commit 3f8d719a11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      slither/detectors/variables/similar_variables.py

@ -65,12 +65,16 @@ class SimilarVarsDetection(AbstractDetector):
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)):
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))

Loading…
Cancel
Save