From 32cbf7b7c8d9634863af6be9defc8a02c780ff82 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 26 Dec 2024 17:15:52 -0500 Subject: Bugfix for text hashing --- stdlib/text.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'stdlib') diff --git a/stdlib/text.c b/stdlib/text.c index 65d4150a..e25e7bc7 100644 --- a/stdlib/text.c +++ b/stdlib/text.c @@ -829,7 +829,7 @@ PUREFUNC public uint64_t Text$hash(const void *obj, const TypeInfo_t*) switch (text->tag) { case TEXT_ASCII: case TEXT_SHORT_ASCII: { const char *bytes = text->tag == TEXT_ASCII ? text->ascii : text->short_ascii; - for (int64_t i = 0; i + 1 < text->length; i++) { + for (int64_t i = 0; i + 1 < text->length; i += 2) { tmp.chunks[0] = (int32_t)bytes[i]; tmp.chunks[1] = (int32_t)bytes[i+1]; siphashadd64bits(&sh, tmp.whole); @@ -840,7 +840,7 @@ PUREFUNC public uint64_t Text$hash(const void *obj, const TypeInfo_t*) } case TEXT_GRAPHEMES: { const int32_t *graphemes = text->graphemes; - for (int64_t i = 0; i + 1 < text->length; i++) { + for (int64_t i = 0; i + 1 < text->length; i += 2) { tmp.chunks[0] = graphemes[i]; tmp.chunks[1] = graphemes[i]; siphashadd64bits(&sh, tmp.whole); -- cgit v1.2.3