Skip to content

Commit 4a4deb0

Browse files
Merge pull request #295 from marius-bughiu/chore/code-review/fnv1a-hasher-comment
docs(StringFnV1AHasher): replace tutorial-style loop comment
2 parents 0f9bfe0 + 0df94d9 commit 4a4deb0

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/Celerity.Hashing/StringFnV1AHasher.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ public int Hash(string key)
3636
uint hash = offsetBasis;
3737
foreach (char c in key)
3838
{
39-
// Convert char to its lower byte; you may also want to consider
40-
// encoding specifics if you deal with non-ASCII characters.
39+
// Fold only the low byte of each UTF-16 code unit. Characters that share a
40+
// low byte but differ in their high byte (i.e., U+0100 and above) collide here; use
41+
// StringFnV1AFullHasher when that distinction matters.
4142
hash ^= (byte)(c & 0xFF);
4243
hash *= fnvPrime;
4344
}

0 commit comments

Comments
 (0)