[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Rewrite mk/checksum/checksum in awk
On 21.08.2020 19:41, Jonathan Perkin wrote:
> Hey all,
> While working on an upgrade to www/grafana, I needed to use the new
> go-modules.mk support. This resulted in over 600 distfiles to verify,
> and the current shell script cannot keep up, with a quadratic runtime
> of over 8 minutes for 'bmake checksum'.
> I took the opportunity to rewrite the script in awk:
> and now it takes less than 4 seconds.
> I'm still working through testing this, aiming to support all of the
> perculiar features of the existing script (who knew "IGNORE" was a
> supported checksum?) and retain 100% compatibility, but figured I'd
> throw it out to others for extra testing and review in the meantime.
I reviewed both programs, and I like it that you replaced "exit 128"
with "exit 1", since the former could easily translate into an "exit 0".
What you call "a_flag" is not a flag, but the algorithm, so it should be
called that. Oh, I see, that would conflict with the "for (algorithm
in", but I'm sure that can be resolved.
When you "sub(suffix", you treat the suffix as a regular expression.
Before, it was treated as a shell pattern. This might make a difference
for ".tar.gz" and similar suffixes.
In some of the "print self" lines the redirection to stderr is missing.
Thank you for adding all the detailed comments.
If you want to write some automatic tests for it, have a look at
regress/infra-unittests/subst.sh or help.sh. The test framework used
there is documented in test.subr. Using this testing framework, it is
quite easy to ensure that both programs behave the same.
Main Index |
Thread Index |