aboutsummaryrefslogtreecommitdiff
path: root/stdlib/bytes.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-01-23 15:33:56 -0500
committerBruce Hill <bruce@bruce-hill.com>2025-01-23 15:33:56 -0500
commitf93dde14496ef784df6b7b3e1de1030a868be985 (patch)
treee4f5bcc1852d13e2f2d853a1f6590ccdd93e18a2 /stdlib/bytes.c
parentc60ea2079fb230213308904cd0966e5481d2d994 (diff)
Overhaul of Text implementation to be more like Cords and have much
better performance for long sequences of repeated concatenation.
Diffstat (limited to 'stdlib/bytes.c')
-rw-r--r--stdlib/bytes.c11
1 files changed, 6 insertions, 5 deletions
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;
}