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

Optimization: use a more efficient regexp for hexadecimal check #1200

Merged
merged 1 commit into from
May 12, 2022
Merged

Optimization: use a more efficient regexp for hexadecimal check #1200

merged 1 commit into from
May 12, 2022

Conversation

BoboTiG
Copy link
Contributor

@BoboTiG BoboTiG commented May 6, 2022

Quick benchmarks (reusing values from ethereum/eth-utils@f0139f0, I know TX hash is irrelevant here, but results should be the same for addresses):

  • When value is hexadecimal string (TX hash):

    • before: 1.0965 sec
    • after : 0.3652 sec (-66.7 %)
  • When value is not hexadecimal string (TX hash + 'g'):

    • before: 1.4546 sec
    • after : 0.7022 sec (-51.7 %)

Quick benchmarks:

- When `value` is hexadecimal string (TX hash):
  - before: 1.0965 sec
  - after : 0.3652 sec (-66.7 %)

- When `value` is not hexadecimal string (TX hash + 'g'):
  - before: 1.4546 sec
  - after : 0.7022 sec (-51.7 %)
@0xalpharush 0xalpharush self-requested a review May 6, 2022 14:33
Copy link
Member

@0xalpharush 0xalpharush left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@montyly
Copy link
Member

montyly commented May 12, 2022

This is great, thanks @BoboTiG

@montyly montyly merged commit 75f858d into crytic:dev May 12, 2022
@BoboTiG BoboTiG deleted the impr-hex-regexp-optimization branch May 12, 2022 10:42
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.

None yet

3 participants