diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2025-10-04 05:05:31 -0400 |
|---|---|---|
| committer | Jacob Young <15544577+jacobly0@users.noreply.github.com> | 2025-10-05 00:25:21 -0400 |
| commit | 906ce2ad7cb3960eb579ab46b79dff3b9eae1ef5 (patch) | |
| tree | 3c6ad18765f6b986e6105f3a91691c6f54f74943 /src/Value.zig | |
| parent | 606c7bcc89dd42be52661fe0a7626803e992308b (diff) | |
| download | zig-906ce2ad7cb3960eb579ab46b79dff3b9eae1ef5.tar.gz zig-906ce2ad7cb3960eb579ab46b79dff3b9eae1ef5.zip | |
InternPool: use sequential string indices instead of byte offsets
This allows more bytes to be referenced by a smaller index range.
Closes #22867
Closes #25297
Closes #25339
Diffstat (limited to 'src/Value.zig')
| -rw-r--r-- | src/Value.zig | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/Value.zig b/src/Value.zig index 381eacf45a..b72ee2f789 100644 --- a/src/Value.zig +++ b/src/Value.zig @@ -66,8 +66,8 @@ pub fn toIpString(val: Value, ty: Type, pt: Zcu.PerThread) !InternPool.NullTermi .repeated_elem => |elem| { const byte: u8 = @intCast(Value.fromInterned(elem).toUnsignedInt(zcu)); const len: u32 = @intCast(ty.arrayLen(zcu)); - const strings = ip.getLocal(pt.tid).getMutableStrings(zcu.gpa); - try strings.appendNTimes(.{byte}, len); + const string_bytes = ip.getLocal(pt.tid).getMutableStringBytes(zcu.gpa); + try string_bytes.appendNTimes(.{byte}, len); return ip.getOrPutTrailingString(zcu.gpa, pt.tid, len, .no_embedded_nulls); }, } @@ -109,16 +109,16 @@ fn arrayToIpString(val: Value, len_u64: u64, pt: Zcu.PerThread) !InternPool.Null const gpa = zcu.gpa; const ip = &zcu.intern_pool; const len: u32 = @intCast(len_u64); - const strings = ip.getLocal(pt.tid).getMutableStrings(gpa); - try strings.ensureUnusedCapacity(len); + const string_bytes = ip.getLocal(pt.tid).getMutableStringBytes(gpa); + try string_bytes.ensureUnusedCapacity(len); for (0..len) |i| { // I don't think elemValue has the possibility to affect ip.string_bytes. Let's // assert just to be sure. - const prev_len = strings.mutate.len; + const prev_len = string_bytes.mutate.len; const elem_val = try val.elemValue(pt, i); - assert(strings.mutate.len == prev_len); + assert(string_bytes.mutate.len == prev_len); const byte: u8 = @intCast(elem_val.toUnsignedInt(zcu)); - strings.appendAssumeCapacity(.{byte}); + string_bytes.appendAssumeCapacity(.{byte}); } return ip.getOrPutTrailingString(gpa, pt.tid, len, .no_embedded_nulls); } |
