mirror of
https://github.com/immich-app/immich.git
synced 2024-12-24 10:37:28 +02: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;
|
||
|
}
|