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...@@ -407,7 +407,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(zigmod.Modul
407/// returns if all of the zig modules in needles are in haystack407/// returns if all of the zig modules in needles are in haystack
408fn contains_all(needles: []zigmod.Module, haystack: []const zigmod.Module) bool {408fn contains_all(needles: []zigmod.Module, haystack: []const zigmod.Module) bool {
409 for (needles) |item| {409 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)) {
411 return false;411 return false;
412 }412 }
413 }413 }
src/cmd/generate.zig+2-1
...@@ -1,5 +1,6 @@...@@ -1,5 +1,6 @@
1const std = @import("std");1const std = @import("std");
2const string = []const u8;2const string = []const u8;
3const extras = @import("extras");
34
4const zigmod = @import("../lib.zig");5const zigmod = @import("../lib.zig");
5const u = @import("./../util/index.zig");6const u = @import("./../util/index.zig");
...@@ -356,7 +357,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, alloc: std.mem.Allocator, cachepath:...@@ -356,7 +357,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, alloc: std.mem.Allocator, cachepath:
356/// returns if all of the zig modules in needles are in haystack357/// returns if all of the zig modules in needles are in haystack
357fn contains_all(needles: []zigmod.Module, haystack: []const zigmod.Module) bool {358fn contains_all(needles: []zigmod.Module, haystack: []const zigmod.Module) bool {
358 for (needles) |item| {359 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)) {
360 return false;361 return false;
361 }362 }
362 }363 }
src/common.zig+1-1
...@@ -90,7 +90,7 @@ pub fn collect_deps(cachepath: string, mdir: std.fs.Dir, dtype: zigmod.Dep.Type,...@@ -90,7 +90,7 @@ pub fn collect_deps(cachepath: string, mdir: std.fs.Dir, dtype: zigmod.Dep.Type,
90}90}
9191
92pub fn collect_pkgs(mod: zigmod.Module, list: *std.ArrayList(zigmod.Module)) anyerror!void {92pub 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)) {
94 return;94 return;
95 }95 }
96 try list.append(mod);96 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 {...@@ -46,15 +46,6 @@ pub fn split(alloc: std.mem.Allocator, in: string, delim: string) ![]string {
46 return list.toOwnedSlice();46 return list.toOwnedSlice();
47}47}
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
58pub fn file_list(alloc: std.mem.Allocator, dpath: string) ![]const string {49pub fn file_list(alloc: std.mem.Allocator, dpath: string) ![]const string {
59 var dir = try std.fs.cwd().openIterableDir(dpath, .{});50 var dir = try std.fs.cwd().openIterableDir(dpath, .{});
60 defer dir.close();51 defer dir.close();