From 0cd4e51f6e8b78790dc2515fe4e9bab30fe853a8 Mon Sep 17 00:00:00 2001 From: araq Date: Mon, 9 Mar 2026 08:48:10 +0100 Subject: [PATCH] progress --- lib/system/strs_v3.nim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/system/strs_v3.nim b/lib/system/strs_v3.nim index 29f505e0e4..9707283964 100644 --- a/lib/system/strs_v3.nim +++ b/lib/system/strs_v3.nim @@ -45,7 +45,9 @@ proc bswap64(x: uint): uint {.importc: "__builtin_bswap64", nodecl, noSideEffect template ssLen(s: SmallString): int = int(s.bytes and 0xFF'u) template setSSLen(s: var SmallString; v: int) = - s.bytes = (s.bytes and 0xFFFFFFFFFFFFFF00'u) or uint(v) + # Single byte store — equivalent to old `s.slen = byte(v)`. + # Accessing a uint via byte* is legal in C (char-pointer aliasing exemption). + cast[ptr byte](addr s.bytes)[] = cast[byte](v) # Pointer to inline chars (offset +1 from `bytes` field / start of struct). # Only valid when s is in memory (var/ptr); forces a load from memory. @@ -502,7 +504,6 @@ proc setLengthStrV2(s: var SmallString; newLen: int) {.compilerRtl.} = proc nimAsgnStrV2(a: var SmallString; b: SmallString) {.compilerRtl, inline.} = if ssLen(b) <= PayloadSize: - nimDestroyStrV1(a) copyMem(addr a, unsafeAddr b, sizeof(SmallString)) else: if addr(a) == unsafeAddr(b): return