hash static method

int hash(
  1. String string
)
override

Hashes the given String with the same algorithm as readStringHash and iterObjectHash.

This method should only be used at compile-time since it is not very fast.

Implementation

static int hash(String string) {
  final bytes = utf8.encode(string);
  var hash = 0xcbf29ce484222325;
  for (var i = 0; i < bytes.length; i++) {
    hash ^= bytes[i];
    hash *= 0x100000001b3;
  }
  return hash;
}