From 09b5242040cf7383263ce03a9e91ebfd6dc0d479 Mon Sep 17 00:00:00 2001 From: Marius Bughiu Date: Thu, 23 Jul 2026 03:17:06 +0300 Subject: [PATCH 1/2] docs(StringFnV1AHasher): replace tutorial-style loop comment The inner-loop comment ("Convert char to its lower byte; you may also want to consider encoding specifics if you deal with non-ASCII characters") read as leftover second-person scaffolding. Replace it with a declarative note describing the actual low-byte-only behavior and the collision it implies, matching the comment style of sibling hashers such as StringDjb2Hasher and StringFnV1AFullHasher. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/Celerity.Hashing/StringFnV1AHasher.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Celerity.Hashing/StringFnV1AHasher.cs b/src/Celerity.Hashing/StringFnV1AHasher.cs index d7e9208..0f9ef4d 100644 --- a/src/Celerity.Hashing/StringFnV1AHasher.cs +++ b/src/Celerity.Hashing/StringFnV1AHasher.cs @@ -36,8 +36,9 @@ public int Hash(string key) uint hash = offsetBasis; foreach (char c in key) { - // Convert char to its lower byte; you may also want to consider - // encoding specifics if you deal with non-ASCII characters. + // Fold only the low byte of each UTF-16 code unit. Characters that share a + // low byte but differ in their high byte (most non-ASCII) collide here; use + // StringFnV1AFullHasher when that distinction matters. hash ^= (byte)(c & 0xFF); hash *= fnvPrime; } From 0df94d92348f8ff62ae17f49ed949576ac072d0f Mon Sep 17 00:00:00 2001 From: Marius Bughiu Date: Thu, 23 Jul 2026 09:13:38 +0300 Subject: [PATCH 2/2] more accurate description of collision risk Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- src/Celerity.Hashing/StringFnV1AHasher.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Celerity.Hashing/StringFnV1AHasher.cs b/src/Celerity.Hashing/StringFnV1AHasher.cs index 0f9ef4d..262d071 100644 --- a/src/Celerity.Hashing/StringFnV1AHasher.cs +++ b/src/Celerity.Hashing/StringFnV1AHasher.cs @@ -37,7 +37,7 @@ public int Hash(string key) foreach (char c in key) { // Fold only the low byte of each UTF-16 code unit. Characters that share a - // low byte but differ in their high byte (most non-ASCII) collide here; use + // low byte but differ in their high byte (i.e., U+0100 and above) collide here; use // StringFnV1AFullHasher when that distinction matters. hash ^= (byte)(c & 0xFF); hash *= fnvPrime;