fastHash function
- String string
FNV-1a 64bit hash algorithm optimized for Dart Strings. This is used to generate integer IDs that can be hard assigned to entities with string IDs with microscopically low collision. This allows for example, a DictionaryHeading's ID to always be determinable by its composite parameters.
Implementation
int fastHash(String string) {
var hash = 0xcbf29ce484222325;
var i = 0;
while (i < string.length) {
final codeUnit = string.codeUnitAt(i++);
hash ^= codeUnit >> 8;
hash *= 0x100000001b3;
hash ^= codeUnit & 0xFF;
hash *= 0x100000001b3;
}
return hash;
}