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

IsHash() is highly inefficient #492

Open
junyer opened this issue Aug 12, 2023 · 0 comments
Open

IsHash() is highly inefficient #492

junyer opened this issue Aug 12, 2023 · 0 comments

Comments

@junyer
Copy link

junyer commented Aug 12, 2023

return Matches(str, "^[a-f0-9]{"+len+"}$")

Currently, IsHash() parses, compiles and matches a regular expression each time, which is highly inefficient in terms of CPU and RAM. Instead, it should check the length of str and then iterate over str to check the digits, which will be a lot faster and won't allocate any memory at all.

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

No branches or pull requests

1 participant