From f93dde14496ef784df6b7b3e1de1030a868be985 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 23 Jan 2025 15:33:56 -0500 Subject: Overhaul of Text implementation to be more like Cords and have much better performance for long sequences of repeated concatenation. --- stdlib/datatypes.h | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'stdlib/datatypes.h') diff --git a/stdlib/datatypes.h b/stdlib/datatypes.h index 11ae130e..80591adc 100644 --- a/stdlib/datatypes.h +++ b/stdlib/datatypes.h @@ -66,18 +66,24 @@ typedef struct Range_s { Int_t first, last, step; } Range_t; -enum text_type { TEXT_SHORT_ASCII, TEXT_ASCII, TEXT_SHORT_GRAPHEMES, TEXT_GRAPHEMES, TEXT_SUBTEXT }; +enum text_type { TEXT_ASCII, TEXT_GRAPHEMES, TEXT_CONCAT }; typedef struct Text_s { - int64_t length; // Number of grapheme clusters - uint64_t hash:61; - uint8_t tag:3; + int64_t length:54; // Number of grapheme clusters + uint8_t depth:8; + uint8_t tag:2; union { - char short_ascii[8]; - const char *ascii; - int32_t short_graphemes[2]; - const int32_t *graphemes; - struct Text_s *subtexts; + struct { + const char *ascii; + // char ascii_buf[8]; + }; + struct { + const int32_t *graphemes; + // int32_t grapheme_buf[2]; + }; + struct { + const struct Text_s *left, *right; + }; }; } Text_t; -- cgit v1.2.3