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

Remove unnecessary DigestMethod().Reset() calls #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

alext
Copy link

@alext alext commented Sep 28, 2024

These simply generate a new hash instance, only to call Reset() on it and then discard it, which is a wasted allocation etc.

They look to be a hangover from before #3 where DigestMethod used to hold a persistent instance of hash.Hash, and therefore needed resetting before each use.

While here, I've also removed an unnecessary anonymous function. DigestMethod is already a func() hash.Hash, so there's no need to wrap it in an anonymous function with the same signature to call it.

These simply generate a new hash instance, only to call Reset() on it
and then discard it, which is a wasted allocation etc.

They look to be a hangover from before 7dd818e where DigestMethod used
to hold a persistent instance of hash.Hash, and therefore needed
resetting before each use.
DigestMethod is already a func() hash.Hash, so there's no longer a need
to wrap it in an anonymous function with the same signature to call it.
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.

1 participant