aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/c.zig
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2023-06-12 01:44:12 -0400
committerAndrew Kelley <andrew@ziglang.org>2023-06-11 23:45:09 -0700
commitd37ebfcf231c68a0430840c4fbe649dd0076ae1e (patch)
treed9f67acedf38600487a2d2ed08e1e202dfad5667 /src/codegen/c.zig
parent54460e39ace2140e6bfcb0bf4ae1709d128f9e8d (diff)
downloadzig-d37ebfcf231c68a0430840c4fbe649dd0076ae1e.tar.gz
zig-d37ebfcf231c68a0430840c4fbe649dd0076ae1e.zip
InternPool: avoid as many slices pointing to `string_bytes` as possible
These are frequently invalidated whenever a string is interned, so avoid creating pointers to `string_bytes` wherever possible. This is an attempt to fix random CI failures.
Diffstat (limited to 'src/codegen/c.zig')
-rw-r--r--src/codegen/c.zig8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig
index 8d2ba2bbb8..c1b7bd72b1 100644
--- a/src/codegen/c.zig
+++ b/src/codegen/c.zig
@@ -1850,9 +1850,9 @@ pub const DeclGen = struct {
try mod.markDeclAlive(decl);
if (mod.decl_exports.get(decl_index)) |exports| {
- try writer.writeAll(mod.intern_pool.stringToSlice(exports.items[export_index].name));
+ try writer.print("{}", .{exports.items[export_index].opts.name.fmt(&mod.intern_pool)});
} else if (decl.isExtern(mod)) {
- try writer.writeAll(mod.intern_pool.stringToSlice(decl.name));
+ try writer.print("{}", .{decl.name.fmt(&mod.intern_pool)});
} else {
// MSVC has a limit of 4095 character token length limit, and fmtIdent can (worst case),
// expand to 3x the length of its input, but let's cut it off at a much shorter limit.
@@ -2481,8 +2481,8 @@ fn genExports(o: *Object) !void {
try fwd_decl_writer.writeAll("zig_export(");
try o.dg.renderFunctionSignature(fwd_decl_writer, o.dg.decl_index.unwrap().?, .forward, .{ .export_index = @intCast(u32, i) });
try fwd_decl_writer.print(", {s}, {s});\n", .{
- fmtStringLiteral(ip.stringToSlice(exports.items[0].name), null),
- fmtStringLiteral(ip.stringToSlice(@"export".name), null),
+ fmtStringLiteral(ip.stringToSlice(exports.items[0].opts.name), null),
+ fmtStringLiteral(ip.stringToSlice(@"export".opts.name), null),
});
}
}