Simplify sha1 functions #111

Merged
lunny merged 1 commits from unknown repository into master 2018-02-10 18:25:25 +00:00
Owner

Author: @ethantkoenig

Some simplifications to prevent wheel re-invention:

  • Use hex.EncodeString(..) instead of manually hex encoding
    • This is likely to be faster, since we don't have to allocate a byte array containg 012..ef each call.
  • Use copy(..) instead of manually copying bytes
    • This is likely to be faster, since copy has architecture-specialized implementations
  • Use bytes.Equal(..) instead of manually comparing bytes
    • Again, this is likely to be faster, since bytes.Equal has architecture-specialized implementations

For the record, converting an array to a slice (arr[:]) does not copy the array.

Author: @ethantkoenig Some simplifications to prevent wheel re-invention: - Use `hex.EncodeString(..)` instead of manually hex encoding - This is likely to be faster, since we don't have to allocate a byte array containg `012..ef` each call. - Use `copy(..)` instead of manually copying bytes - This is likely to be faster, since `copy` has architecture-specialized implementations - Use `bytes.Equal(..)` instead of manually comparing bytes - Again, this is likely to be faster, since `bytes.Equal` has architecture-specialized implementations For the record, converting an array to a slice (`arr[:]`) does *not* copy the array.
Author
Owner

Author: @lunny

LGTM

Author: @lunny LGTM
This repo is archived. You cannot comment on pull requests.
No description provided.