mirror of
https://github.com/immich-app/immich.git
synced 2024-11-17 19:08:49 -07:00
16 lines
343 B
Dart
16 lines
343 B
Dart
|
/// FNV-1a 64bit hash algorithm optimized for Dart Strings
|
||
|
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;
|
||
|
}
|