mirror of
https://github.com/immich-app/immich.git
synced 2024-12-21 01:39:59 +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;
|
||
|
}
|