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/bytes.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'stdlib/bytes.c') diff --git a/stdlib/bytes.c b/stdlib/bytes.c index 6c94c054..1e889f6d 100644 --- a/stdlib/bytes.c +++ b/stdlib/bytes.c @@ -17,15 +17,16 @@ PUREFUNC public Text_t Byte$as_text(const void *b, bool colorize, const TypeInfo } public Text_t Byte$hex(Byte_t byte, bool uppercase, bool prefix) { - Text_t text = {.tag=TEXT_SHORT_ASCII}; + struct Text_s text = {.tag=TEXT_ASCII}; + text.ascii = GC_MALLOC_ATOMIC(8); if (prefix && uppercase) - text.length = (int64_t)snprintf(text.short_ascii, sizeof(text.short_ascii), "0x%02X", byte); + text.length = (int64_t)snprintf((char*)text.ascii, 8, "0x%02X", byte); else if (prefix && !uppercase) - text.length = (int64_t)snprintf(text.short_ascii, sizeof(text.short_ascii), "0x%02x", byte); + text.length = (int64_t)snprintf((char*)text.ascii, 8, "0x%02x", byte); else if (!prefix && uppercase) - text.length = (int64_t)snprintf(text.short_ascii, sizeof(text.short_ascii), "%02X", byte); + text.length = (int64_t)snprintf((char*)text.ascii, 8, "%02X", byte); else if (!prefix && !uppercase) - text.length = (int64_t)snprintf(text.short_ascii, sizeof(text.short_ascii), "%02x", byte); + text.length = (int64_t)snprintf((char*)text.ascii, 8, "%02x", byte); return text; } -- cgit v1.2.3