"caches" successful hash algorithms for a given checkfile #257
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The goal, based on a sort of principle of locality (or just the typical way checkfiles are generated), is to improve real-world performance by inferring the correct hash algorithm based on previous successes in the same run. I imagine in most cases there will be exactly one successful algorithm per checkfile, but this implementation supports arbitrarily many.
I've tried to make the minimal changes to the existing code necessary to achieve this; integrating in that way always makes the code feel potentially a little messy to me, but it also seems the most friendly way to offer changes. I tried to preserve the existing style even when it didn't match my own. Because of the bitwise markers used to manage the hash-check routines in the existing code, I didn't see an immediately obvious cleaner way to perform the kind of "caching" I wanted to perform.
I'm not sure if anyone needs this, but the use case I have in mind is a checkfile generated in the typical way by rhash or a program that supports a singular algorithm (sha512sum or whatever). Run over large files or many files, it is potentially quite wasteful to walk through every algorithm for a particular size of a message digest.
See also #256.