chmduquesne / rollinghash

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

Refactoring + optimization #14

Open greatroar opened 4 years ago

greatroar commented 4 years ago

Here's some refactoring of the common code for dealing with rolling windows.

The first patch factors out the WriteWindow methods to a function in an internal package. The WriteWindow methods are now so small that they get inlined, so callers still do a single function call (not counting the Write calls).

The second factors out the re-arranging, while changing the algorithm to operate in-place (no allocation).