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

Additional optimizations for similar_variables.py #1980

Merged
merged 2 commits into from
Jun 22, 2023

Conversation

0xGusMcCrae
Copy link
Contributor

Issue #1630

Adding in the additional optimizations for the similar variable name detector as described in #1945 (comment)

Changes:

  • length check brought out of similar into detect_sim. If the lengths aren't the same, no need to run v2.name.lower()
  • v1.name.lower() and v2.name.lower() are cached in detect_sim and given as inputs for similar so that .lower() doesn't have to be run an extra 2 times in the SequenceMatcher call.

Again running on the C4 contest Maia codebase:

Current slither/dev:

ncalls  tottime  percall  cumtime  percall filename:lineno(function)

40      0.004    0.000    17.769   0.444   .../slither/detectors/variables/similar_variables.py:83(_detect)

With new optimizations:

ncalls  tottime  percall  cumtime  percall filename:lineno(function)

40      0.004    0.000    14.867   0.372   .../slither/detectors/variables/similar_variables.py:84(_detect) 

Detected issues unchanged, ~16% reduction in runtime.

@montyly
Copy link
Member

montyly commented Jun 22, 2023

This is great, thanks @0xGusMcCrae for all these optimizations

@montyly montyly merged commit 3af38ff into crytic:dev Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants