From bc032de1dfc8ad03ed7d6ab0471140f393c74532 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 9 Sep 2024 04:42:36 -0400 Subject: Add Text$compare_values() --- builtins/text.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'builtins/text.c') diff --git a/builtins/text.c b/builtins/text.c index 784da410..6fedd82e 100644 --- a/builtins/text.c +++ b/builtins/text.c @@ -905,22 +905,26 @@ PUREFUNC public int32_t Text$compare(const Text_t *a, const Text_t *b) return 0; } -PUREFUNC public bool Text$equal(const Text_t *a, const Text_t *b) +PUREFUNC public bool Text$equal_values(Text_t a, Text_t b) { - if (a == b) return true; - - if (a->length != b->length || (a->hash != 0 && b->hash != 0 && a->hash != b->hash)) + if (a.length != b.length || (a.hash != 0 && b.hash != 0 && a.hash != b.hash)) return false; - int64_t len = a->length; + int64_t len = a.length; text_iter_t a_state = {0, 0}, b_state = {0, 0}; for (int64_t i = 0; i < len; i++) { - int32_t ai = _get_grapheme(*a, &a_state, i); - int32_t bi = _get_grapheme(*b, &b_state, i); + int32_t ai = _get_grapheme(a, &a_state, i); + int32_t bi = _get_grapheme(b, &b_state, i); if (ai != bi) return false; } return true; } +PUREFUNC public bool Text$equal(const Text_t *a, const Text_t *b) +{ + if (a == b) return true; + return Text$equal_values(*a, *b); +} + PUREFUNC public bool Text$equal_ignoring_case(Text_t a, Text_t b) { if (a.length != b.length) -- cgit v1.2.3