authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-11-24 01:04:41 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-11-24 01:04:41 -08:00
logc4ee5cd5a47e0b973bea0a1efd4c5316d7db02f0
tree941383460314fa03f432f1bb607068b79c9cba4a
parent271e7f758da34d2865cec4220e009bff6baccb92

util: drop list_contains_gen


4 files changed, 4 insertions(+), 12 deletions(-)

src/cmd/fetch.zig+1-1
......@@ -407,7 +407,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(zigmod.Modul
407407/// returns if all of the zig modules in needles are in haystack
408408fn contains_all(needles: []zigmod.Module, haystack: []const zigmod.Module) bool {
409409 for (needles) |item| {
410 if (item.main.len > 0 and !u.list_contains_gen(zigmod.Module, haystack, item)) {
410 if (item.main.len > 0 and !extras.containsAggregate(zigmod.Module, haystack, item)) {
411411 return false;
412412 }
413413 }
src/cmd/generate.zig+2-1
......@@ -1,5 +1,6 @@
11const std = @import("std");
22const string = []const u8;
3const extras = @import("extras");
34
45const zigmod = @import("../lib.zig");
56const u = @import("./../util/index.zig");
......@@ -356,7 +357,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, alloc: std.mem.Allocator, cachepath:
356357/// returns if all of the zig modules in needles are in haystack
357358fn contains_all(needles: []zigmod.Module, haystack: []const zigmod.Module) bool {
358359 for (needles) |item| {
359 if (item.main.len > 0 and !u.list_contains_gen(zigmod.Module, haystack, item)) {
360 if (item.main.len > 0 and !extras.containsAggregate(zigmod.Module, haystack, item)) {
360361 return false;
361362 }
362363 }
src/common.zig+1-1
......@@ -90,7 +90,7 @@ pub fn collect_deps(cachepath: string, mdir: std.fs.Dir, dtype: zigmod.Dep.Type,
9090}
9191
9292pub fn collect_pkgs(mod: zigmod.Module, list: *std.ArrayList(zigmod.Module)) anyerror!void {
93 if (u.list_contains_gen(zigmod.Module, list.items, mod)) {
93 if (extras.containsAggregate(zigmod.Module, list.items, mod)) {
9494 return;
9595 }
9696 try list.append(mod);
src/util/funcs.zig-9
......@@ -46,15 +46,6 @@ pub fn split(alloc: std.mem.Allocator, in: string, delim: string) ![]string {
4646 return list.toOwnedSlice();
4747}
4848
49pub fn list_contains_gen(comptime T: type, haystack: []const T, needle: T) bool {
50 for (haystack) |item| {
51 if (item.eql(needle)) {
52 return true;
53 }
54 }
55 return false;
56}
57
5849pub fn file_list(alloc: std.mem.Allocator, dpath: string) ![]const string {
5950 var dir = try std.fs.cwd().openIterableDir(dpath, .{});
6051 defer dir.close();