From 0631fb21c1726c55518d63792399919d6119a9b7 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 2 May 2025 17:15:30 -0400 Subject: Bugfix for text hashing --- src/stdlib/text.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/stdlib/text.c') 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); } -- cgit v1.2.3