authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2023-05-04 18:05:40-07:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2023-05-13 13:45:04-07:00
log815e53b147a321d0bdb47dc008aa8181f57175ac
treedc4b4107c3fa8a50032d6d916a57a1718a445fc9
parentce9f3ec990cd556f2a9d06a6db2bb53e97a61172

Update all std.mem.tokenize calls to their appropriate function

Everywhere that can now use `tokenizeScalar` should get a nice little performance boost.

24 files changed, 79 insertions(+), 79 deletions(-)

build.zig+4-4
......@@ -284,7 +284,7 @@ pub fn build(b: *std.Build) !void {
284284 // That means we also have to rely on stage1 compiled c++ files. We parse config.h to find
285285 // the information passed on to us from cmake.
286286 if (cfg.cmake_prefix_path.len > 0) {
287 var it = mem.tokenize(u8, cfg.cmake_prefix_path, ";");
287 var it = mem.tokenizeScalar(u8, cfg.cmake_prefix_path, ';');
288288 while (it.next()) |path| {
289289 b.addSearchPrefix(path);
290290 }
......@@ -687,7 +687,7 @@ fn addCxxKnownPath(
687687 if (!std.process.can_spawn)
688688 return error.RequiredLibraryNotFound;
689689 const path_padded = b.exec(&.{ ctx.cxx_compiler, b.fmt("-print-file-name={s}", .{objname}) });
690 var tokenizer = mem.tokenize(u8, path_padded, "\r\n");
690 var tokenizer = mem.tokenizeAny(u8, path_padded, "\r\n");
691691 const path_unpadded = tokenizer.next().?;
692692 if (mem.eql(u8, path_unpadded, objname)) {
693693 if (errtxt) |msg| {
......@@ -710,7 +710,7 @@ fn addCxxKnownPath(
710710}
711711
712712fn addCMakeLibraryList(exe: *std.Build.Step.Compile, list: []const u8) void {
713 var it = mem.tokenize(u8, list, ";");
713 var it = mem.tokenizeScalar(u8, list, ';');
714714 while (it.next()) |lib| {
715715 if (mem.startsWith(u8, lib, "-l")) {
716716 exe.linkSystemLibrary(lib["-l".len..]);
......@@ -855,7 +855,7 @@ fn parseConfigH(b: *std.Build, config_h_text: []const u8) ?CMakeConfig {
855855 // .prefix = ZIG_LLVM_LINK_MODE parsed manually below
856856 };
857857
858 var lines_it = mem.tokenize(u8, config_h_text, "\r\n");
858 var lines_it = mem.tokenizeAny(u8, config_h_text, "\r\n");
859859 while (lines_it.next()) |line| {
860860 inline for (mappings) |mapping| {
861861 if (mem.startsWith(u8, line, mapping.prefix)) {
lib/std/Build.zig+1-1
......@@ -1358,7 +1358,7 @@ pub fn findProgram(self: *Build, names: []const []const u8, paths: []const []con
13581358 if (fs.path.isAbsolute(name)) {
13591359 return name;
13601360 }
1361 var it = mem.tokenize(u8, PATH, &[_]u8{fs.path.delimiter});
1361 var it = mem.tokenizeScalar(u8, PATH, fs.path.delimiter);
13621362 while (it.next()) |path| {
13631363 const full_path = self.pathJoin(&.{
13641364 path,
lib/std/Build/Cache.zig+2-2
......@@ -434,7 +434,7 @@ pub const Manifest = struct {
434434
435435 const input_file_count = self.files.items.len;
436436 var any_file_changed = false;
437 var line_iter = mem.tokenize(u8, file_contents, "\n");
437 var line_iter = mem.tokenizeScalar(u8, file_contents, '\n');
438438 var idx: usize = 0;
439439 if (if (line_iter.next()) |line| !std.mem.eql(u8, line, manifest_header) else true) {
440440 if (try self.upgradeToExclusiveLock()) continue;
......@@ -463,7 +463,7 @@ pub const Manifest = struct {
463463 break :blk new;
464464 };
465465
466 var iter = mem.tokenize(u8, line, " ");
466 var iter = mem.tokenizeScalar(u8, line, ' ');
467467 const size = iter.next() orelse return error.InvalidFormat;
468468 const inode = iter.next() orelse return error.InvalidFormat;
469469 const mtime_nsec_str = iter.next() orelse return error.InvalidFormat;
lib/std/Build/Step/CheckObject.zig+4-4
......@@ -103,8 +103,8 @@ const Action = struct {
103103 assert(act.tag == .match or act.tag == .not_present);
104104 const phrase = act.phrase.resolve(b, step);
105105 var candidate_var: ?struct { name: []const u8, value: u64 } = null;
106 var hay_it = mem.tokenize(u8, mem.trim(u8, haystack, " "), " ");
107 var needle_it = mem.tokenize(u8, mem.trim(u8, phrase, " "), " ");
106 var hay_it = mem.tokenizeScalar(u8, mem.trim(u8, haystack, " "), ' ');
107 var needle_it = mem.tokenizeScalar(u8, mem.trim(u8, phrase, " "), ' ');
108108
109109 while (needle_it.next()) |needle_tok| {
110110 const hay_tok = hay_it.next() orelse return false;
......@@ -155,7 +155,7 @@ const Action = struct {
155155 var op_stack = std.ArrayList(enum { add, sub, mod, mul }).init(gpa);
156156 var values = std.ArrayList(u64).init(gpa);
157157
158 var it = mem.tokenize(u8, phrase, " ");
158 var it = mem.tokenizeScalar(u8, phrase, ' ');
159159 while (it.next()) |next| {
160160 if (mem.eql(u8, next, "+")) {
161161 try op_stack.append(.add);
......@@ -365,7 +365,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
365365 var vars = std.StringHashMap(u64).init(gpa);
366366
367367 for (self.checks.items) |chk| {
368 var it = mem.tokenize(u8, output, "\r\n");
368 var it = mem.tokenizeAny(u8, output, "\r\n");
369369 for (chk.actions.items) |act| {
370370 switch (act.tag) {
371371 .match => {
lib/std/Build/Step/Compile.zig+3-3
......@@ -777,7 +777,7 @@ fn runPkgConfig(self: *Compile, lib_name: []const u8) ![]const []const u8 {
777777 var zig_args = ArrayList([]const u8).init(b.allocator);
778778 defer zig_args.deinit();
779779
780 var it = mem.tokenize(u8, stdout, " \r\n\t");
780 var it = mem.tokenizeAny(u8, stdout, " \r\n\t");
781781 while (it.next()) |tok| {
782782 if (mem.eql(u8, tok, "-I")) {
783783 const dir = it.next() orelse return error.PkgConfigInvalidOutput;
......@@ -2017,10 +2017,10 @@ fn execPkgConfigList(self: *std.Build, out_code: *u8) (PkgConfigError || ExecErr
20172017 const stdout = try self.execAllowFail(&[_][]const u8{ "pkg-config", "--list-all" }, out_code, .Ignore);
20182018 var list = ArrayList(PkgConfigPkg).init(self.allocator);
20192019 errdefer list.deinit();
2020 var line_it = mem.tokenize(u8, stdout, "\r\n");
2020 var line_it = mem.tokenizeAny(u8, stdout, "\r\n");
20212021 while (line_it.next()) |line| {
20222022 if (mem.trim(u8, line, " \t").len == 0) continue;
2023 var tok_it = mem.tokenize(u8, line, " \t");
2023 var tok_it = mem.tokenizeAny(u8, line, " \t");
20242024 try list.append(PkgConfigPkg{
20252025 .name = tok_it.next() orelse return error.PkgConfigInvalidOutput,
20262026 .desc = tok_it.rest(),
lib/std/Build/Step/ConfigHeader.zig+2-2
......@@ -257,7 +257,7 @@ fn render_autoconf(
257257 try output.appendSlice("\n");
258258 continue;
259259 }
260 var it = std.mem.tokenize(u8, line[1..], " \t\r");
260 var it = std.mem.tokenizeAny(u8, line[1..], " \t\r");
261261 const undef = it.next().?;
262262 if (!std.mem.eql(u8, undef, "undef")) {
263263 try output.appendSlice(line);
......@@ -304,7 +304,7 @@ fn render_cmake(
304304 try output.appendSlice("\n");
305305 continue;
306306 }
307 var it = std.mem.tokenize(u8, line[1..], " \t\r");
307 var it = std.mem.tokenizeAny(u8, line[1..], " \t\r");
308308 const cmakedefine = it.next().?;
309309 if (!std.mem.eql(u8, cmakedefine, "cmakedefine") and
310310 !std.mem.eql(u8, cmakedefine, "cmakedefine01"))
lib/std/child_process.zig+2-2
......@@ -850,7 +850,7 @@ pub const ChildProcess = struct {
850850 return original_err;
851851 }
852852
853 var it = mem.tokenize(u16, PATH, &[_]u16{';'});
853 var it = mem.tokenizeScalar(u16, PATH, ';');
854854 while (it.next()) |search_path| {
855855 dir_buf.clearRetainingCapacity();
856856 try dir_buf.appendSlice(self.allocator, search_path);
......@@ -1067,7 +1067,7 @@ fn windowsCreateProcessPathExt(
10671067 // Now we know that at least *a* file matching the wildcard exists, we can loop
10681068 // through PATHEXT in order and exec any that exist
10691069
1070 var ext_it = mem.tokenize(u16, pathext, &[_]u16{';'});
1070 var ext_it = mem.tokenizeScalar(u16, pathext, ';');
10711071 while (ext_it.next()) |ext| {
10721072 if (!windowsCreateProcessSupportsExtension(ext)) continue;
10731073
lib/std/fs.zig+1-1
......@@ -3021,7 +3021,7 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 {
30213021 } else if (argv0.len != 0) {
30223022 // argv[0] is not empty (and not a path): search it inside PATH
30233023 const PATH = std.os.getenvZ("PATH") orelse return error.FileNotFound;
3024 var path_it = mem.tokenize(u8, PATH, &[_]u8{path.delimiter});
3024 var path_it = mem.tokenizeScalar(u8, PATH, path.delimiter);
30253025 while (path_it.next()) |a_path| {
30263026 var resolved_path_buf: [MAX_PATH_BYTES - 1:0]u8 = undefined;
30273027 const resolved_path = std.fmt.bufPrintZ(&resolved_path_buf, "{s}/{s}", .{
lib/std/fs/path.zig+13-13
......@@ -358,7 +358,7 @@ pub fn windowsParsePath(path: []const u8) WindowsPath {
358358 return relative_path;
359359 }
360360
361 var it = mem.tokenize(u8, path, &[_]u8{this_sep});
361 var it = mem.tokenizeScalar(u8, path, this_sep);
362362 _ = (it.next() orelse return relative_path);
363363 _ = (it.next() orelse return relative_path);
364364 return WindowsPath{
......@@ -420,8 +420,8 @@ fn networkShareServersEql(ns1: []const u8, ns2: []const u8) bool {
420420 const sep1 = ns1[0];
421421 const sep2 = ns2[0];
422422
423 var it1 = mem.tokenize(u8, ns1, &[_]u8{sep1});
424 var it2 = mem.tokenize(u8, ns2, &[_]u8{sep2});
423 var it1 = mem.tokenizeScalar(u8, ns1, sep1);
424 var it2 = mem.tokenizeScalar(u8, ns2, sep2);
425425
426426 // TODO ASCII is wrong, we actually need full unicode support to compare paths.
427427 return ascii.eqlIgnoreCase(it1.next().?, it2.next().?);
......@@ -441,8 +441,8 @@ fn compareDiskDesignators(kind: WindowsPath.Kind, p1: []const u8, p2: []const u8
441441 const sep1 = p1[0];
442442 const sep2 = p2[0];
443443
444 var it1 = mem.tokenize(u8, p1, &[_]u8{sep1});
445 var it2 = mem.tokenize(u8, p2, &[_]u8{sep2});
444 var it1 = mem.tokenizeScalar(u8, p1, sep1);
445 var it2 = mem.tokenizeScalar(u8, p2, sep2);
446446
447447 // TODO ASCII is wrong, we actually need full unicode support to compare paths.
448448 return ascii.eqlIgnoreCase(it1.next().?, it2.next().?) and ascii.eqlIgnoreCase(it1.next().?, it2.next().?);
......@@ -535,7 +535,7 @@ pub fn resolveWindows(allocator: Allocator, paths: []const []const u8) ![]u8 {
535535 break :l disk_designator.len;
536536 },
537537 .NetworkShare => {
538 var it = mem.tokenize(u8, paths[first_index], "/\\");
538 var it = mem.tokenizeAny(u8, paths[first_index], "/\\");
539539 const server_name = it.next().?;
540540 const other_name = it.next().?;
541541
......@@ -570,7 +570,7 @@ pub fn resolveWindows(allocator: Allocator, paths: []const []const u8) ![]u8 {
570570 if (!correct_disk_designator) {
571571 continue;
572572 }
573 var it = mem.tokenize(u8, p[parsed.disk_designator.len..], "/\\");
573 var it = mem.tokenizeAny(u8, p[parsed.disk_designator.len..], "/\\");
574574 while (it.next()) |component| {
575575 if (mem.eql(u8, component, ".")) {
576576 continue;
......@@ -657,7 +657,7 @@ pub fn resolvePosix(allocator: Allocator, paths: []const []const u8) Allocator.E
657657 negative_count = 0;
658658 result.clearRetainingCapacity();
659659 }
660 var it = mem.tokenize(u8, p, "/");
660 var it = mem.tokenizeScalar(u8, p, '/');
661661 while (it.next()) |component| {
662662 if (mem.eql(u8, component, ".")) {
663663 continue;
......@@ -1078,8 +1078,8 @@ pub fn relativeWindows(allocator: Allocator, from: []const u8, to: []const u8) !
10781078 return resolved_to;
10791079 }
10801080
1081 var from_it = mem.tokenize(u8, resolved_from, "/\\");
1082 var to_it = mem.tokenize(u8, resolved_to, "/\\");
1081 var from_it = mem.tokenizeAny(u8, resolved_from, "/\\");
1082 var to_it = mem.tokenizeAny(u8, resolved_to, "/\\");
10831083 while (true) {
10841084 const from_component = from_it.next() orelse return allocator.dupe(u8, to_it.rest());
10851085 const to_rest = to_it.rest();
......@@ -1102,7 +1102,7 @@ pub fn relativeWindows(allocator: Allocator, from: []const u8, to: []const u8) !
11021102 result_index += 3;
11031103 }
11041104
1105 var rest_it = mem.tokenize(u8, to_rest, "/\\");
1105 var rest_it = mem.tokenizeAny(u8, to_rest, "/\\");
11061106 while (rest_it.next()) |to_component| {
11071107 result[result_index] = '\\';
11081108 result_index += 1;
......@@ -1124,8 +1124,8 @@ pub fn relativePosix(allocator: Allocator, from: []const u8, to: []const u8) ![]
11241124 const resolved_to = try resolvePosix(allocator, &[_][]const u8{ cwd, to });
11251125 defer allocator.free(resolved_to);
11261126
1127 var from_it = mem.tokenize(u8, resolved_from, "/");
1128 var to_it = mem.tokenize(u8, resolved_to, "/");
1127 var from_it = mem.tokenizeScalar(u8, resolved_from, '/');
1128 var to_it = mem.tokenizeScalar(u8, resolved_to, '/');
11291129 while (true) {
11301130 const from_component = from_it.next() orelse return allocator.dupe(u8, to_it.rest());
11311131 const to_rest = to_it.rest();
lib/std/http/Client.zig+2-2
......@@ -386,7 +386,7 @@ pub const Response = struct {
386386 };
387387
388388 pub fn parse(res: *Response, bytes: []const u8, trailing: bool) ParseError!void {
389 var it = mem.tokenize(u8, bytes[0 .. bytes.len - 4], "\r\n");
389 var it = mem.tokenizeAny(u8, bytes[0 .. bytes.len - 4], "\r\n");
390390
391391 const first_line = it.next() orelse return error.HttpHeadersInvalid;
392392 if (first_line.len < 12)
......@@ -412,7 +412,7 @@ pub const Response = struct {
412412 else => {},
413413 }
414414
415 var line_it = mem.tokenize(u8, line, ": ");
415 var line_it = mem.tokenizeAny(u8, line, ": ");
416416 const header_name = line_it.next() orelse return error.HttpHeadersInvalid;
417417 const header_value = line_it.rest();
418418
lib/std/http/Server.zig+2-2
......@@ -231,7 +231,7 @@ pub const Request = struct {
231231 };
232232
233233 pub fn parse(req: *Request, bytes: []const u8) ParseError!void {
234 var it = mem.tokenize(u8, bytes[0 .. bytes.len - 4], "\r\n");
234 var it = mem.tokenizeAny(u8, bytes[0 .. bytes.len - 4], "\r\n");
235235
236236 const first_line = it.next() orelse return error.HttpHeadersInvalid;
237237 if (first_line.len < 10)
......@@ -265,7 +265,7 @@ pub const Request = struct {
265265 else => {},
266266 }
267267
268 var line_it = mem.tokenize(u8, line, ": ");
268 var line_it = mem.tokenizeAny(u8, line, ": ");
269269 const header_name = line_it.next() orelse return error.HttpHeadersInvalid;
270270 const header_value = line_it.rest();
271271
lib/std/net.zig+3-3
......@@ -1266,7 +1266,7 @@ fn linuxLookupNameFromHosts(
12661266 var split_it = mem.split(u8, line, "#");
12671267 const no_comment_line = split_it.first();
12681268
1269 var line_it = mem.tokenize(u8, no_comment_line, " \t");
1269 var line_it = mem.tokenizeAny(u8, no_comment_line, " \t");
12701270 const ip_text = line_it.next() orelse continue;
12711271 var first_name_text: ?[]const u8 = null;
12721272 while (line_it.next()) |name_text| {
......@@ -1346,7 +1346,7 @@ fn linuxLookupNameFromDnsSearch(
13461346 @memcpy(canon.items, canon_name);
13471347 try canon.append('.');
13481348
1349 var tok_it = mem.tokenize(u8, search, " \t");
1349 var tok_it = mem.tokenizeAny(u8, search, " \t");
13501350 while (tok_it.next()) |tok| {
13511351 canon.shrinkRetainingCapacity(canon_name.len + 1);
13521352 try canon.appendSlice(tok);
......@@ -1468,7 +1468,7 @@ fn getResolvConf(allocator: mem.Allocator, rc: *ResolvConf) !void {
14681468 var split = mem.split(u8, line, "#");
14691469 break :no_comment_line split.first();
14701470 };
1471 var line_it = mem.tokenize(u8, no_comment_line, " \t");
1471 var line_it = mem.tokenizeAny(u8, no_comment_line, " \t");
14721472
14731473 const token = line_it.next() orelse continue;
14741474 if (mem.eql(u8, token, "options")) {
lib/std/os.zig+1-1
......@@ -1878,7 +1878,7 @@ pub fn execvpeZ_expandArg0(
18781878 // Use of MAX_PATH_BYTES here is valid as the path_buf will be passed
18791879 // directly to the operating system in execveZ.
18801880 var path_buf: [MAX_PATH_BYTES]u8 = undefined;
1881 var it = mem.tokenize(u8, PATH, ":");
1881 var it = mem.tokenizeScalar(u8, PATH, ':');
18821882 var seen_eacces = false;
18831883 var err: ExecveError = error.FileNotFound;
18841884
lib/std/process.zig+1-1
......@@ -1200,7 +1200,7 @@ fn totalSystemMemoryLinux() !usize {
12001200 var buf: [50]u8 = undefined;
12011201 const amt = try file.read(&buf);
12021202 if (amt != 50) return error.Unexpected;
1203 var it = std.mem.tokenize(u8, buf[0..amt], " \n");
1203 var it = std.mem.tokenizeAny(u8, buf[0..amt], " \n");
12041204 const label = it.next().?;
12051205 if (!std.mem.eql(u8, label, "MemTotal:")) return error.Unexpected;
12061206 const int_text = it.next() orelse return error.Unexpected;
lib/std/zig/system/NativePaths.zig+5-5
......@@ -31,7 +31,7 @@ pub fn detect(allocator: Allocator, native_info: NativeTargetInfo) !NativePaths
3131 defer allocator.free(nix_cflags_compile);
3232
3333 is_nix = true;
34 var it = mem.tokenize(u8, nix_cflags_compile, " ");
34 var it = mem.tokenizeScalar(u8, nix_cflags_compile, ' ');
3535 while (true) {
3636 const word = it.next() orelse break;
3737 if (mem.eql(u8, word, "-isystem")) {
......@@ -62,7 +62,7 @@ pub fn detect(allocator: Allocator, native_info: NativeTargetInfo) !NativePaths
6262 defer allocator.free(nix_ldflags);
6363
6464 is_nix = true;
65 var it = mem.tokenize(u8, nix_ldflags, " ");
65 var it = mem.tokenizeScalar(u8, nix_ldflags, ' ');
6666 while (true) {
6767 const word = it.next() orelse break;
6868 if (mem.eql(u8, word, "-rpath")) {
......@@ -147,21 +147,21 @@ pub fn detect(allocator: Allocator, native_info: NativeTargetInfo) !NativePaths
147147 // We use os.getenv here since this part won't be executed on
148148 // windows, to get rid of unnecessary error handling.
149149 if (std.os.getenv("C_INCLUDE_PATH")) |c_include_path| {
150 var it = mem.tokenize(u8, c_include_path, ":");
150 var it = mem.tokenizeScalar(u8, c_include_path, ':');
151151 while (it.next()) |dir| {
152152 try self.addIncludeDir(dir);
153153 }
154154 }
155155
156156 if (std.os.getenv("CPLUS_INCLUDE_PATH")) |cplus_include_path| {
157 var it = mem.tokenize(u8, cplus_include_path, ":");
157 var it = mem.tokenizeScalar(u8, cplus_include_path, ':');
158158 while (it.next()) |dir| {
159159 try self.addIncludeDir(dir);
160160 }
161161 }
162162
163163 if (std.os.getenv("LIBRARY_PATH")) |library_path| {
164 var it = mem.tokenize(u8, library_path, ":");
164 var it = mem.tokenizeScalar(u8, library_path, ':');
165165 while (it.next()) |dir| {
166166 try self.addLibDir(dir);
167167 }
lib/std/zig/system/NativeTargetInfo.zig+2-2
......@@ -354,7 +354,7 @@ fn detectAbiAndDynamicLinker(
354354 const newline = mem.indexOfScalar(u8, buffer[0..len], '\n') orelse break :blk file;
355355 const line = buffer[0..newline];
356356 if (!mem.startsWith(u8, line, "#!")) break :blk file;
357 var it = mem.tokenize(u8, line[2..], " ");
357 var it = mem.tokenizeScalar(u8, line[2..], ' ');
358358 file_name = it.next() orelse return defaultAbiAndDynamicLinker(cpu, os, cross_target);
359359 file.close();
360360 }
......@@ -811,7 +811,7 @@ pub fn abiAndDynamicLinkerFromFile(
811811 const strtab = strtab_buf[0..strtab_read_len];
812812
813813 const rpath_list = mem.sliceTo(strtab, 0);
814 var it = mem.tokenize(u8, rpath_list, ":");
814 var it = mem.tokenizeScalar(u8, rpath_list, ':');
815815 while (it.next()) |rpath| {
816816 if (glibcVerFromRPath(rpath)) |ver| {
817817 result.target.os.version_range.linux.glibc = ver;
src/arch/x86_64/CodeGen.zig+3-3
......@@ -8409,9 +8409,9 @@ fn airAsm(self: *Self, inst: Air.Inst.Index) !void {
84098409 }
84108410
84118411 const asm_source = mem.sliceAsBytes(self.air.extra[extra_i..])[0..extra.data.source_len];
8412 var line_it = mem.tokenize(u8, asm_source, "\n\r;");
8412 var line_it = mem.tokenizeAny(u8, asm_source, "\n\r;");
84138413 while (line_it.next()) |line| {
8414 var mnem_it = mem.tokenize(u8, line, " \t");
8414 var mnem_it = mem.tokenizeAny(u8, line, " \t");
84158415 const mnem_str = mnem_it.next() orelse continue;
84168416 if (mem.startsWith(u8, mnem_str, "#")) continue;
84178417
......@@ -8435,7 +8435,7 @@ fn airAsm(self: *Self, inst: Air.Inst.Index) !void {
84358435 return self.fail("Invalid mnemonic: '{s}'", .{mnem_str});
84368436 } };
84378437
8438 var op_it = mem.tokenize(u8, mnem_it.rest(), ",");
8438 var op_it = mem.tokenizeScalar(u8, mnem_it.rest(), ',');
84398439 var ops = [1]encoder.Instruction.Operand{.none} ** 4;
84408440 for (&ops) |*op| {
84418441 const op_str = mem.trim(u8, op_it.next() orelse break, " \t");
src/glibc.zig+1-1
......@@ -109,7 +109,7 @@ pub fn loadMetaData(gpa: Allocator, contents: []const u8) LoadMetaDataError!*ABI
109109 const target_name = mem.sliceTo(contents[index..], 0);
110110 index += target_name.len + 1;
111111
112 var component_it = mem.tokenize(u8, target_name, "-");
112 var component_it = mem.tokenizeScalar(u8, target_name, '-');
113113 const arch_name = component_it.next() orelse {
114114 log.err("abilists: expected arch name", .{});
115115 return error.ZigInstallationCorrupt;
src/libc_installation.zig+4-4
......@@ -60,7 +60,7 @@ pub const LibCInstallation = struct {
6060 const contents = try std.fs.cwd().readFileAlloc(allocator, libc_file, std.math.maxInt(usize));
6161 defer allocator.free(contents);
6262
63 var it = std.mem.tokenize(u8, contents, "\n");
63 var it = std.mem.tokenizeScalar(u8, contents, '\n');
6464 while (it.next()) |line| {
6565 if (line.len == 0 or line[0] == '#') continue;
6666 var line_it = std.mem.split(u8, line, "=");
......@@ -293,7 +293,7 @@ pub const LibCInstallation = struct {
293293 },
294294 }
295295
296 var it = std.mem.tokenize(u8, exec_res.stderr, "\n\r");
296 var it = std.mem.tokenizeAny(u8, exec_res.stderr, "\n\r");
297297 var search_paths = std.ArrayList([]const u8).init(allocator);
298298 defer search_paths.deinit();
299299 while (it.next()) |line| {
......@@ -613,7 +613,7 @@ fn ccPrintFileName(args: CCPrintFileNameOptions) ![:0]u8 {
613613 },
614614 }
615615
616 var it = std.mem.tokenize(u8, exec_res.stdout, "\n\r");
616 var it = std.mem.tokenizeAny(u8, exec_res.stdout, "\n\r");
617617 const line = it.next() orelse return error.LibCRuntimeNotFound;
618618 // When this command fails, it returns exit code 0 and duplicates the input file name.
619619 // So we detect failure by checking if the output matches exactly the input.
......@@ -692,7 +692,7 @@ fn appendCcExe(args: *std.ArrayList([]const u8), skip_cc_env_var: bool) !void {
692692 return;
693693 };
694694 // Respect space-separated flags to the C compiler.
695 var it = std.mem.tokenize(u8, cc_env_var, " ");
695 var it = std.mem.tokenizeScalar(u8, cc_env_var, ' ');
696696 while (it.next()) |arg| {
697697 try args.append(arg);
698698 }
src/link/Plan9.zig+1-1
......@@ -264,7 +264,7 @@ fn putFn(self: *Plan9, decl_index: Module.Decl.Index, out: FnDeclOutput) !void {
264264
265265fn addPathComponents(self: *Plan9, path: []const u8, a: *std.ArrayList(u8)) !void {
266266 const sep = std.fs.path.sep;
267 var it = std.mem.tokenize(u8, path, &.{sep});
267 var it = std.mem.tokenizeScalar(u8, path, sep);
268268 while (it.next()) |component| {
269269 if (self.file_segments.get(component)) |num| {
270270 try a.writer().writeIntBig(u16, num);
src/print_zir.zig+1-1
......@@ -2581,7 +2581,7 @@ const Writer = struct {
25812581 fn writeDocComment(self: *Writer, stream: anytype, doc_comment_index: u32) !void {
25822582 if (doc_comment_index != 0) {
25832583 const doc_comment = self.code.nullTerminatedString(doc_comment_index);
2584 var it = std.mem.tokenize(u8, doc_comment, "\n");
2584 var it = std.mem.tokenizeScalar(u8, doc_comment, '\n');
25852585 while (it.next()) |doc_line| {
25862586 try stream.writeByteNTimes(' ', self.indent);
25872587 try stream.print("///{s}\n", .{doc_line});
test/behavior/bugs/6456.zig+1-1
......@@ -18,7 +18,7 @@ test "issue 6456" {
1818 comptime {
1919 var fields: []const StructField = &[0]StructField{};
2020
21 var it = std.mem.tokenize(u8, text, "\n");
21 var it = std.mem.tokenizeScalar(u8, text, '\n');
2222 while (it.next()) |name| {
2323 fields = fields ++ &[_]StructField{StructField{
2424 .alignment = 0,
test/src/Cases.zig+2-2
......@@ -846,7 +846,7 @@ const TestManifest = struct {
846846 const actual_start = start orelse return error.MissingTestManifest;
847847 const manifest_bytes = bytes[actual_start..end];
848848
849 var it = std.mem.tokenize(u8, manifest_bytes, "\r\n");
849 var it = std.mem.tokenizeAny(u8, manifest_bytes, "\r\n");
850850
851851 // First line is the test type
852852 const tt: Type = blk: {
......@@ -923,7 +923,7 @@ const TestManifest = struct {
923923
924924 fn trailing(self: TestManifest) TrailingIterator {
925925 return .{
926 .inner = std.mem.tokenize(u8, self.trailing_bytes, "\r\n"),
926 .inner = std.mem.tokenizeAny(u8, self.trailing_bytes, "\r\n"),
927927 };
928928 }
929929
tools/generate_linux_syscalls.zig+18-18
......@@ -51,11 +51,11 @@ pub fn main() !void {
5151 try writer.writeAll("pub const X86 = enum(usize) {\n");
5252
5353 const table = try linux_dir.readFile("arch/x86/entry/syscalls/syscall_32.tbl", buf);
54 var lines = mem.tokenize(u8, table, "\n");
54 var lines = mem.tokenizeScalar(u8, table, '\n');
5555 while (lines.next()) |line| {
5656 if (line[0] == '#') continue;
5757
58 var fields = mem.tokenize(u8, line, " \t");
58 var fields = mem.tokenizeAny(u8, line, " \t");
5959 const number = fields.next() orelse return error.Incomplete;
6060 // abi is always i386
6161 _ = fields.next() orelse return error.Incomplete;
......@@ -70,11 +70,11 @@ pub fn main() !void {
7070 try writer.writeAll("pub const X64 = enum(usize) {\n");
7171
7272 const table = try linux_dir.readFile("arch/x86/entry/syscalls/syscall_64.tbl", buf);
73 var lines = mem.tokenize(u8, table, "\n");
73 var lines = mem.tokenizeScalar(u8, table, '\n');
7474 while (lines.next()) |line| {
7575 if (line[0] == '#') continue;
7676
77 var fields = mem.tokenize(u8, line, " \t");
77 var fields = mem.tokenizeAny(u8, line, " \t");
7878 const number = fields.next() orelse return error.Incomplete;
7979 const abi = fields.next() orelse return error.Incomplete;
8080 // The x32 abi syscalls are always at the end.
......@@ -96,11 +96,11 @@ pub fn main() !void {
9696 );
9797
9898 const table = try linux_dir.readFile("arch/arm/tools/syscall.tbl", buf);
99 var lines = mem.tokenize(u8, table, "\n");
99 var lines = mem.tokenizeScalar(u8, table, '\n');
100100 while (lines.next()) |line| {
101101 if (line[0] == '#') continue;
102102
103 var fields = mem.tokenize(u8, line, " \t");
103 var fields = mem.tokenizeAny(u8, line, " \t");
104104 const number = fields.next() orelse return error.Incomplete;
105105 const abi = fields.next() orelse return error.Incomplete;
106106 if (mem.eql(u8, abi, "oabi")) continue;
......@@ -127,11 +127,11 @@ pub fn main() !void {
127127 {
128128 try writer.writeAll("pub const Sparc64 = enum(usize) {\n");
129129 const table = try linux_dir.readFile("arch/sparc/kernel/syscalls/syscall.tbl", buf);
130 var lines = mem.tokenize(u8, table, "\n");
130 var lines = mem.tokenizeScalar(u8, table, '\n');
131131 while (lines.next()) |line| {
132132 if (line[0] == '#') continue;
133133
134 var fields = mem.tokenize(u8, line, " \t");
134 var fields = mem.tokenizeAny(u8, line, " \t");
135135 const number = fields.next() orelse return error.Incomplete;
136136 const abi = fields.next() orelse return error.Incomplete;
137137 if (mem.eql(u8, abi, "32")) continue;
......@@ -151,11 +151,11 @@ pub fn main() !void {
151151 );
152152
153153 const table = try linux_dir.readFile("arch/mips/kernel/syscalls/syscall_o32.tbl", buf);
154 var lines = mem.tokenize(u8, table, "\n");
154 var lines = mem.tokenizeScalar(u8, table, '\n');
155155 while (lines.next()) |line| {
156156 if (line[0] == '#') continue;
157157
158 var fields = mem.tokenize(u8, line, " \t");
158 var fields = mem.tokenizeAny(u8, line, " \t");
159159 const number = fields.next() orelse return error.Incomplete;
160160 // abi is always o32
161161 _ = fields.next() orelse return error.Incomplete;
......@@ -176,11 +176,11 @@ pub fn main() !void {
176176 );
177177
178178 const table = try linux_dir.readFile("arch/mips/kernel/syscalls/syscall_n64.tbl", buf);
179 var lines = mem.tokenize(u8, table, "\n");
179 var lines = mem.tokenizeScalar(u8, table, '\n');
180180 while (lines.next()) |line| {
181181 if (line[0] == '#') continue;
182182
183 var fields = mem.tokenize(u8, line, " \t");
183 var fields = mem.tokenizeAny(u8, line, " \t");
184184 const number = fields.next() orelse return error.Incomplete;
185185 // abi is always n64
186186 _ = fields.next() orelse return error.Incomplete;
......@@ -197,11 +197,11 @@ pub fn main() !void {
197197
198198 const table = try linux_dir.readFile("arch/powerpc/kernel/syscalls/syscall.tbl", buf);
199199 var list_64 = std.ArrayList(u8).init(allocator);
200 var lines = mem.tokenize(u8, table, "\n");
200 var lines = mem.tokenizeScalar(u8, table, '\n');
201201 while (lines.next()) |line| {
202202 if (line[0] == '#') continue;
203203
204 var fields = mem.tokenize(u8, line, " \t");
204 var fields = mem.tokenizeAny(u8, line, " \t");
205205 const number = fields.next() orelse return error.Incomplete;
206206 const abi = fields.next() orelse return error.Incomplete;
207207 const name = fields.next() orelse return error.Incomplete;
......@@ -277,9 +277,9 @@ pub fn main() !void {
277277 },
278278 };
279279
280 var lines = mem.tokenize(u8, defines, "\n");
280 var lines = mem.tokenizeScalar(u8, defines, '\n');
281281 loop: while (lines.next()) |line| {
282 var fields = mem.tokenize(u8, line, " \t");
282 var fields = mem.tokenizeAny(u8, line, " \t");
283283 const cmd = fields.next() orelse return error.Incomplete;
284284 if (!mem.eql(u8, cmd, "#define")) continue;
285285 const define = fields.next() orelse return error.Incomplete;
......@@ -339,9 +339,9 @@ pub fn main() !void {
339339 },
340340 };
341341
342 var lines = mem.tokenize(u8, defines, "\n");
342 var lines = mem.tokenizeScalar(u8, defines, '\n');
343343 loop: while (lines.next()) |line| {
344 var fields = mem.tokenize(u8, line, " \t");
344 var fields = mem.tokenizeAny(u8, line, " \t");
345345 const cmd = fields.next() orelse return error.Incomplete;
346346 if (!mem.eql(u8, cmd, "#define")) continue;
347347 const define = fields.next() orelse return error.Incomplete;