authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-09-18 00:53:23 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-09-18 00:53:23 -07:00
logec980d58a02151b3f39508be69d4ffea588b0850
tree7089fb490afc945c68425187491d682c7733a210
parent014d13f8a3ca27359ee2b48b1e83e60c6df78f33

remove dependence on non-const temporaries


2 files changed, 6 insertions(+), 3 deletions(-)

src/cmd/fetch.zig+4-2
...@@ -109,13 +109,14 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D...@@ -109,13 +109,14 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
109109
110 try w.writeAll("pub const package_data = struct {\n");110 try w.writeAll("pub const package_data = struct {\n");
111 var duped = std.ArrayList(zigmod.Module).init(alloc);111 var duped = std.ArrayList(zigmod.Module).init(alloc);
112 var done = std.ArrayList(zigmod.Module).init(alloc);
112 for (list.items) |mod| {113 for (list.items) |mod| {
113 if (mod.type == .system_lib or mod.type == .framework) {114 if (mod.type == .system_lib or mod.type == .framework) {
114 continue;115 continue;
115 }116 }
116 try duped.append(mod);117 try duped.append(mod);
117 }118 }
118 try print_pkg_data_to(w, &duped, &std.ArrayList(zigmod.Module).init(alloc));119 try print_pkg_data_to(w, &duped, &done);
119 try w.writeAll("};\n\n");120 try w.writeAll("};\n\n");
120121
121 try w.writeAll("pub const packages = ");122 try w.writeAll("pub const packages = ");
...@@ -159,7 +160,8 @@ fn diff_lockfile(alloc: std.mem.Allocator) !void {...@@ -159,7 +160,8 @@ fn diff_lockfile(alloc: std.mem.Allocator) !void {
159160
160 if (try u.does_folder_exist(".git")) {161 if (try u.does_folder_exist(".git")) {
161 const result = try u.run_cmd_raw(alloc, null, &.{ "git", "diff", "zigmod.lock" });162 const result = try u.run_cmd_raw(alloc, null, &.{ "git", "diff", "zigmod.lock" });
162 const r = std.io.fixedBufferStream(result.stdout).reader();163 var stdout = std.io.fixedBufferStream(result.stdout);
164 const r = stdout.reader();
163 while (try r.readUntilDelimiterOrEofAlloc(alloc, '\n', max)) |line| {165 while (try r.readUntilDelimiterOrEofAlloc(alloc, '\n', max)) |line| {
164 if (std.mem.startsWith(u8, line, "@@")) break;166 if (std.mem.startsWith(u8, line, "@@")) break;
165 }167 }
src/cmd/generate.zig+2-1
...@@ -189,13 +189,14 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D...@@ -189,13 +189,14 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
189189
190 try w.writeAll("pub const package_data = struct {\n");190 try w.writeAll("pub const package_data = struct {\n");
191 var duped = std.ArrayList(zigmod.Module).init(alloc);191 var duped = std.ArrayList(zigmod.Module).init(alloc);
192 var done = std.ArrayList(zigmod.Module).init(alloc);
192 for (list) |mod| {193 for (list) |mod| {
193 if (mod.type == .system_lib or mod.type == .framework) {194 if (mod.type == .system_lib or mod.type == .framework) {
194 continue;195 continue;
195 }196 }
196 try duped.append(mod);197 try duped.append(mod);
197 }198 }
198 try print_pkg_data_to(w, alloc, cachepath, &duped, &std.ArrayList(zigmod.Module).init(alloc));199 try print_pkg_data_to(w, alloc, cachepath, &duped, &done);
199 try w.writeAll("};\n\n");200 try w.writeAll("};\n\n");
200201
201 try w.writeAll("pub const packages = ");202 try w.writeAll("pub const packages = ");