diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-05-02 17:15:30 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-05-02 17:15:30 -0400 |
| commit | 0631fb21c1726c55518d63792399919d6119a9b7 (patch) | |
| tree | ef84122d70f16af1ce947df67be14c587a85cd27 /src | |
| parent | 4f6bfe722ae5e91d955859ec11efe839181033b7 (diff) | |
Bugfix for text hashing
Diffstat (limited to 'src')
| -rw-r--r-- | src/stdlib/text.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/stdlib/text.c b/src/stdlib/text.c index 2b49cc12..8607e165 100644 --- a/src/stdlib/text.c +++ b/src/stdlib/text.c @@ -861,7 +861,7 @@ PUREFUNC public uint64_t Text$hash(const void *obj, const TypeInfo_t *info) const int32_t *graphemes = text.graphemes; for (int64_t i = 0; i + 1 < text.length; i += 2) { tmp.chunks[0] = graphemes[i]; - tmp.chunks[1] = graphemes[i]; + tmp.chunks[1] = graphemes[i+1]; siphashadd64bits(&sh, tmp.whole); } int32_t last = text.length & 0x1 ? graphemes[text.length-1] : 0; // Odd number of graphemes @@ -869,9 +869,9 @@ PUREFUNC public uint64_t Text$hash(const void *obj, const TypeInfo_t *info) } case TEXT_CONCAT: { TextIter_t state = NEW_TEXT_ITER_STATE(text); - for (int64_t i = 0; i < (text.length & ~0x1); i += 2) { + for (int64_t i = 0; i + 1 < text.length; i += 2) { tmp.chunks[0] = Text$get_grapheme_fast(&state, i); - tmp.chunks[0] = Text$get_grapheme_fast(&state, i+1); + tmp.chunks[1] = Text$get_grapheme_fast(&state, i+1); siphashadd64bits(&sh, tmp.whole); } |
