authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-09-18 11:15:53 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-09-18 11:15:53 -07:00
logd2bedba959d5237145318d9feb424f914bfcdf74
treea4d976bb55f2741aa60437bd0ca443af3d5e42d5
parent67caed05c15bee558beb29dd5f33d38cac874e89

dry: u.list_contains -> extras.containsString


5 files changed, 8 insertions(+), 16 deletions(-)

src/cmd/license.zig+2-1
......@@ -2,6 +2,7 @@ const std = @import("std");
22const gpa = std.heap.c_allocator;
33const style = @import("ansi").style;
44const licenses = @import("licenses");
5const extras = @import("extras");
56
67const zigmod = @import("../lib.zig");
78const u = @import("./../util/index.zig");
......@@ -77,7 +78,7 @@ pub fn execute(args: [][]u8) !void {
7778 first = false;
7879 try writer.writeAll(Bold);
7980 try writer.print("{s}:\n", .{entry.key_ptr.*});
80 if (u.list_contains(licenses.spdx, entry.key_ptr.*)) {
81 if (extras.containsString(licenses.spdx, entry.key_ptr.*)) {
8182 try writer.writeAll(Faint);
8283 try writer.print("= {s}{s}\n", .{ "https://spdx.org/licenses/", entry.key_ptr.* });
8384 }
src/common.zig+2-2
......@@ -104,8 +104,8 @@ pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) !
104104 const pv = try std.fs.path.join(options.alloc, &.{ cachepath, try d.clean_path_v(options.alloc) });
105105
106106 const nocache = d.type.isLocal();
107 if (!nocache and u.list_contains(options.already_fetched.items, p)) return p;
108 if (!nocache and u.list_contains(options.already_fetched.items, pv)) return pv;
107 if (!nocache and extras.containsString(options.already_fetched.items, p)) return p;
108 if (!nocache and extras.containsString(options.already_fetched.items, pv)) return pv;
109109
110110 if (options.log and d.type != .local) {
111111 std.debug.print("fetch: {s}: {s}\n", .{ @tagName(d.type), d.path });
src/util/dep.zig+2-2
......@@ -56,10 +56,10 @@ pub const Dep = struct {
5656 pub fn is_for_this(self: Dep) bool {
5757 const os = @tagName(builtin.os.tag);
5858 if (self.only_os.len > 0) {
59 return u.list_contains(self.only_os, os);
59 return extras.containsString(self.only_os, os);
6060 }
6161 if (self.except_os.len > 0) {
62 return !u.list_contains(self.except_os, os);
62 return !extras.containsString(self.except_os, os);
6363 }
6464 return true;
6565 }
src/util/funcs.zig-9
......@@ -75,15 +75,6 @@ pub fn trim_suffix(in: string, suffix: string) string {
7575 return in;
7676}
7777
78pub fn list_contains(haystack: []const string, needle: string) bool {
79 for (haystack) |item| {
80 if (std.mem.eql(u8, item, needle)) {
81 return true;
82 }
83 }
84 return false;
85}
86
8778pub fn list_contains_gen(comptime T: type, haystack: []const T, needle: T) bool {
8879 for (haystack) |item| {
8980 if (item.eql(needle)) {
src/util/module.zig+2-2
......@@ -98,10 +98,10 @@ pub const Module = struct {
9898 pub fn is_for_this(self: Module) bool {
9999 const os = @tagName(builtin.os.tag);
100100 if (self.only_os.len > 0) {
101 return u.list_contains(self.only_os, os);
101 return extras.containsString(self.only_os, os);
102102 }
103103 if (self.except_os.len > 0) {
104 return !u.list_contains(self.except_os, os);
104 return !extras.containsString(self.except_os, os);
105105 }
106106 return true;
107107 }