authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-03-17 19:12:22-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-05-25 18:54:34-07:00
loge436d9c4ad623d8facefb8e1637b26e63e900277
tree9b3ef08620cd9392b91f68c8958a4ef429880bd1
parentc6d37f389591e722f59ca7f2b719ec8cfc0a9984

configurer: back out the string interning from prev commit

partial revert of 2d3fbb687fba1ed52b42998ac4dcbf2a042644ea - see its commit message for reasoning

2 files changed, 8 insertions(+), 14 deletions(-)

lib/std/Build.zig+7-13
......@@ -122,22 +122,16 @@ pub const Graph = struct {
122122 return @enumFromInt(graph.generated_files.items.len - 1);
123123 }
124124
125 pub fn dupeString(graph: *Graph, bytes: []const u8) [:0]const u8 {
126 // This code assumes the `Configuration.Wip` uses arena allocation such
127 // that references to string_bytes never die even when the ArrayList is
128 // reallocated.
129 const wc = &graph.wip_configuration;
130 const i = wc.addString(bytes) catch @panic("OOM");
131 return wc.string_bytes.items[@intFromEnum(i)..][0..bytes.len :0];
125 pub fn dupeString(graph: *Graph, bytes: []const u8) []const u8 {
126 return graph.arena.dupe(u8, bytes) catch @panic("OOM");
132127 }
133128
134 pub fn dupePath(graph: *Graph, bytes: []const u8) [:0]const u8 {
135 if (builtin.os.tag != .windows) return dupeString(graph, bytes);
129 pub fn dupePath(graph: *Graph, bytes: []const u8) []const u8 {
136130 const arena = graph.arena;
131 if (builtin.os.tag != .windows) return graph.arena.dupe(u8, bytes) catch @panic("OOM");
137132 const the_copy = arena.dupe(u8, bytes) catch @panic("OOM");
138 defer arena.free(the_copy);
139133 mem.replaceScalar(u8, the_copy, '/', '\\');
140 return dupeString(graph, the_copy);
134 return the_copy;
141135 }
142136
143137 pub fn dupeStrings(graph: *Graph, strings: []const []const u8) []const []const u8 {
......@@ -895,7 +889,7 @@ pub fn addConfigHeader(
895889 return config_header_step;
896890}
897891
898pub fn dupe(b: *Build, bytes: []const u8) [:0]const u8 {
892pub fn dupe(b: *Build, bytes: []const u8) []const u8 {
899893 return b.graph.dupeString(bytes);
900894}
901895
......@@ -905,7 +899,7 @@ pub fn dupeStrings(b: *Build, strings: []const []const u8) []const []const u8 {
905899}
906900
907901/// Duplicates a path, canonicalizing path separators.
908pub fn dupePath(b: *Build, bytes: []const u8) [:0]const u8 {
902pub fn dupePath(b: *Build, bytes: []const u8) []const u8 {
909903 return b.graph.dupePath(bytes);
910904}
911905
lib/std/Build/Step/Run.zig+1-1
......@@ -139,7 +139,7 @@ pub const Arg = union(enum) {
139139 lazy_path: PrefixedLazyPath,
140140 decorated_directory: DecoratedLazyPath,
141141 file_content: PrefixedLazyPath,
142 bytes: [:0]const u8,
142 bytes: []const u8,
143143 output_file: *Output,
144144 output_directory: *Output,
145145 /// The arguments passed after "--" on the "zig build" CLI.