chmduquesne / rollinghash

Implementation of some rolling hashes in go
MIT License
64 stars 11 forks source link

Further reduce allocations in adler32.Write #3

Closed calmh closed 7 years ago

calmh commented 7 years ago

So I missed that our usage pattern, in one case, is a Reset(), Write(), Reset(), Write() loop, which still causes an allocation for the window on every iteration. This adds an ugly, nested if that fixes that. It's not super beautiful, but it's a huge win in terms of allocations for that pattern...

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 66.667% when pulling 9d57f4e5038de6e4177547daf3db4773d49c9961 on kastelo:reduceallocs2 into 001f23736d5530d53d1588d3c1127b68caee99af on chmduquesne:master.

chmduquesne commented 7 years ago

Makes sense with your usage pattern. I'll have to see if I can unify that accross all rollinghashes implementations.