igorkamyshev / farfetched

The advanced data fetching tool for web applications
https://ff.effector.dev
MIT License
190 stars 34 forks source link

Replace sha1 hash with simpler algorithm #489

Closed zerobias closed 2 months ago

zerobias commented 4 months ago

Sha1 implementation in farfetched is very large and probably not so fast. We don't need cryptography-grade implementation for that case, so we can pick much simpler implementation from effector/babel-plugin:

function hashCode(s: string) {
  let h = 0
  let i = 0
  while (i < s.length) h = ((h << 5) - h + s.charCodeAt(i++)) | 0
  return h.toString(36)
}

It's came from java and battle-tested in effector itself

igorkamyshev commented 2 months ago

Done https://github.com/igorkamyshev/farfetched/commit/88b6096d7f61d8010c2da359cbe99b3760887387