| author | |
| committer | |
| log | 815e53b147a321d0bdb47dc008aa8181f57175ac |
| tree | dc4b4107c3fa8a50032d6d916a57a1718a445fc9 |
| parent | ce9f3ec990cd556f2a9d06a6db2bb53e97a61172 |
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 { |
| 284 | 284 | // That means we also have to rely on stage1 compiled c++ files. We parse config.h to find |
| 285 | 285 | // the information passed on to us from cmake. |
| 286 | 286 | 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, ';'); | |
| 288 | 288 | while (it.next()) |path| { |
| 289 | 289 | b.addSearchPrefix(path); |
| 290 | 290 | } |
| ... | ... | @@ -687,7 +687,7 @@ fn addCxxKnownPath( |
| 687 | 687 | if (!std.process.can_spawn) |
| 688 | 688 | return error.RequiredLibraryNotFound; |
| 689 | 689 | 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"); | |
| 691 | 691 | const path_unpadded = tokenizer.next().?; |
| 692 | 692 | if (mem.eql(u8, path_unpadded, objname)) { |
| 693 | 693 | if (errtxt) |msg| { |
| ... | ... | @@ -710,7 +710,7 @@ fn addCxxKnownPath( |
| 710 | 710 | } |
| 711 | 711 | |
| 712 | 712 | fn addCMakeLibraryList(exe: *std.Build.Step.Compile, list: []const u8) void { |
| 713 | var it = mem.tokenize(u8, list, ";"); | |
| 713 | var it = mem.tokenizeScalar(u8, list, ';'); | |
| 714 | 714 | while (it.next()) |lib| { |
| 715 | 715 | if (mem.startsWith(u8, lib, "-l")) { |
| 716 | 716 | exe.linkSystemLibrary(lib["-l".len..]); |
| ... | ... | @@ -855,7 +855,7 @@ fn parseConfigH(b: *std.Build, config_h_text: []const u8) ?CMakeConfig { |
| 855 | 855 | // .prefix = ZIG_LLVM_LINK_MODE parsed manually below |
| 856 | 856 | }; |
| 857 | 857 | |
| 858 | var lines_it = mem.tokenize(u8, config_h_text, "\r\n"); | |
| 858 | var lines_it = mem.tokenizeAny(u8, config_h_text, "\r\n"); | |
| 859 | 859 | while (lines_it.next()) |line| { |
| 860 | 860 | inline for (mappings) |mapping| { |
| 861 | 861 | 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 |
| 1358 | 1358 | if (fs.path.isAbsolute(name)) { |
| 1359 | 1359 | return name; |
| 1360 | 1360 | } |
| 1361 | var it = mem.tokenize(u8, PATH, &[_]u8{fs.path.delimiter}); | |
| 1361 | var it = mem.tokenizeScalar(u8, PATH, fs.path.delimiter); | |
| 1362 | 1362 | while (it.next()) |path| { |
| 1363 | 1363 | const full_path = self.pathJoin(&.{ |
| 1364 | 1364 | path, |
lib/std/Build/Cache.zig+2-2| ... | ... | @@ -434,7 +434,7 @@ pub const Manifest = struct { |
| 434 | 434 | |
| 435 | 435 | const input_file_count = self.files.items.len; |
| 436 | 436 | 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'); | |
| 438 | 438 | var idx: usize = 0; |
| 439 | 439 | if (if (line_iter.next()) |line| !std.mem.eql(u8, line, manifest_header) else true) { |
| 440 | 440 | if (try self.upgradeToExclusiveLock()) continue; |
| ... | ... | @@ -463,7 +463,7 @@ pub const Manifest = struct { |
| 463 | 463 | break :blk new; |
| 464 | 464 | }; |
| 465 | 465 | |
| 466 | var iter = mem.tokenize(u8, line, " "); | |
| 466 | var iter = mem.tokenizeScalar(u8, line, ' '); | |
| 467 | 467 | const size = iter.next() orelse return error.InvalidFormat; |
| 468 | 468 | const inode = iter.next() orelse return error.InvalidFormat; |
| 469 | 469 | 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 { |
| 103 | 103 | assert(act.tag == .match or act.tag == .not_present); |
| 104 | 104 | const phrase = act.phrase.resolve(b, step); |
| 105 | 105 | 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, " "), ' '); | |
| 108 | 108 | |
| 109 | 109 | while (needle_it.next()) |needle_tok| { |
| 110 | 110 | const hay_tok = hay_it.next() orelse return false; |
| ... | ... | @@ -155,7 +155,7 @@ const Action = struct { |
| 155 | 155 | var op_stack = std.ArrayList(enum { add, sub, mod, mul }).init(gpa); |
| 156 | 156 | var values = std.ArrayList(u64).init(gpa); |
| 157 | 157 | |
| 158 | var it = mem.tokenize(u8, phrase, " "); | |
| 158 | var it = mem.tokenizeScalar(u8, phrase, ' '); | |
| 159 | 159 | while (it.next()) |next| { |
| 160 | 160 | if (mem.eql(u8, next, "+")) { |
| 161 | 161 | try op_stack.append(.add); |
| ... | ... | @@ -365,7 +365,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { |
| 365 | 365 | var vars = std.StringHashMap(u64).init(gpa); |
| 366 | 366 | |
| 367 | 367 | for (self.checks.items) |chk| { |
| 368 | var it = mem.tokenize(u8, output, "\r\n"); | |
| 368 | var it = mem.tokenizeAny(u8, output, "\r\n"); | |
| 369 | 369 | for (chk.actions.items) |act| { |
| 370 | 370 | switch (act.tag) { |
| 371 | 371 | .match => { |
lib/std/Build/Step/Compile.zig+3-3| ... | ... | @@ -777,7 +777,7 @@ fn runPkgConfig(self: *Compile, lib_name: []const u8) ![]const []const u8 { |
| 777 | 777 | var zig_args = ArrayList([]const u8).init(b.allocator); |
| 778 | 778 | defer zig_args.deinit(); |
| 779 | 779 | |
| 780 | var it = mem.tokenize(u8, stdout, " \r\n\t"); | |
| 780 | var it = mem.tokenizeAny(u8, stdout, " \r\n\t"); | |
| 781 | 781 | while (it.next()) |tok| { |
| 782 | 782 | if (mem.eql(u8, tok, "-I")) { |
| 783 | 783 | const dir = it.next() orelse return error.PkgConfigInvalidOutput; |
| ... | ... | @@ -2017,10 +2017,10 @@ fn execPkgConfigList(self: *std.Build, out_code: *u8) (PkgConfigError || ExecErr |
| 2017 | 2017 | const stdout = try self.execAllowFail(&[_][]const u8{ "pkg-config", "--list-all" }, out_code, .Ignore); |
| 2018 | 2018 | var list = ArrayList(PkgConfigPkg).init(self.allocator); |
| 2019 | 2019 | errdefer list.deinit(); |
| 2020 | var line_it = mem.tokenize(u8, stdout, "\r\n"); | |
| 2020 | var line_it = mem.tokenizeAny(u8, stdout, "\r\n"); | |
| 2021 | 2021 | while (line_it.next()) |line| { |
| 2022 | 2022 | 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"); | |
| 2024 | 2024 | try list.append(PkgConfigPkg{ |
| 2025 | 2025 | .name = tok_it.next() orelse return error.PkgConfigInvalidOutput, |
| 2026 | 2026 | .desc = tok_it.rest(), |
lib/std/Build/Step/ConfigHeader.zig+2-2| ... | ... | @@ -257,7 +257,7 @@ fn render_autoconf( |
| 257 | 257 | try output.appendSlice("\n"); |
| 258 | 258 | continue; |
| 259 | 259 | } |
| 260 | var it = std.mem.tokenize(u8, line[1..], " \t\r"); | |
| 260 | var it = std.mem.tokenizeAny(u8, line[1..], " \t\r"); | |
| 261 | 261 | const undef = it.next().?; |
| 262 | 262 | if (!std.mem.eql(u8, undef, "undef")) { |
| 263 | 263 | try output.appendSlice(line); |
| ... | ... | @@ -304,7 +304,7 @@ fn render_cmake( |
| 304 | 304 | try output.appendSlice("\n"); |
| 305 | 305 | continue; |
| 306 | 306 | } |
| 307 | var it = std.mem.tokenize(u8, line[1..], " \t\r"); | |
| 307 | var it = std.mem.tokenizeAny(u8, line[1..], " \t\r"); | |
| 308 | 308 | const cmakedefine = it.next().?; |
| 309 | 309 | if (!std.mem.eql(u8, cmakedefine, "cmakedefine") and |
| 310 | 310 | !std.mem.eql(u8, cmakedefine, "cmakedefine01")) |
lib/std/child_process.zig+2-2| ... | ... | @@ -850,7 +850,7 @@ pub const ChildProcess = struct { |
| 850 | 850 | return original_err; |
| 851 | 851 | } |
| 852 | 852 | |
| 853 | var it = mem.tokenize(u16, PATH, &[_]u16{';'}); | |
| 853 | var it = mem.tokenizeScalar(u16, PATH, ';'); | |
| 854 | 854 | while (it.next()) |search_path| { |
| 855 | 855 | dir_buf.clearRetainingCapacity(); |
| 856 | 856 | try dir_buf.appendSlice(self.allocator, search_path); |
| ... | ... | @@ -1067,7 +1067,7 @@ fn windowsCreateProcessPathExt( |
| 1067 | 1067 | // Now we know that at least *a* file matching the wildcard exists, we can loop |
| 1068 | 1068 | // through PATHEXT in order and exec any that exist |
| 1069 | 1069 | |
| 1070 | var ext_it = mem.tokenize(u16, pathext, &[_]u16{';'}); | |
| 1070 | var ext_it = mem.tokenizeScalar(u16, pathext, ';'); | |
| 1071 | 1071 | while (ext_it.next()) |ext| { |
| 1072 | 1072 | if (!windowsCreateProcessSupportsExtension(ext)) continue; |
| 1073 | 1073 |
lib/std/fs.zig+1-1| ... | ... | @@ -3021,7 +3021,7 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 { |
| 3021 | 3021 | } else if (argv0.len != 0) { |
| 3022 | 3022 | // argv[0] is not empty (and not a path): search it inside PATH |
| 3023 | 3023 | 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); | |
| 3025 | 3025 | while (path_it.next()) |a_path| { |
| 3026 | 3026 | var resolved_path_buf: [MAX_PATH_BYTES - 1:0]u8 = undefined; |
| 3027 | 3027 | 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 { |
| 358 | 358 | return relative_path; |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | var it = mem.tokenize(u8, path, &[_]u8{this_sep}); | |
| 361 | var it = mem.tokenizeScalar(u8, path, this_sep); | |
| 362 | 362 | _ = (it.next() orelse return relative_path); |
| 363 | 363 | _ = (it.next() orelse return relative_path); |
| 364 | 364 | return WindowsPath{ |
| ... | ... | @@ -420,8 +420,8 @@ fn networkShareServersEql(ns1: []const u8, ns2: []const u8) bool { |
| 420 | 420 | const sep1 = ns1[0]; |
| 421 | 421 | const sep2 = ns2[0]; |
| 422 | 422 | |
| 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); | |
| 425 | 425 | |
| 426 | 426 | // TODO ASCII is wrong, we actually need full unicode support to compare paths. |
| 427 | 427 | return ascii.eqlIgnoreCase(it1.next().?, it2.next().?); |
| ... | ... | @@ -441,8 +441,8 @@ fn compareDiskDesignators(kind: WindowsPath.Kind, p1: []const u8, p2: []const u8 |
| 441 | 441 | const sep1 = p1[0]; |
| 442 | 442 | const sep2 = p2[0]; |
| 443 | 443 | |
| 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); | |
| 446 | 446 | |
| 447 | 447 | // TODO ASCII is wrong, we actually need full unicode support to compare paths. |
| 448 | 448 | 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 { |
| 535 | 535 | break :l disk_designator.len; |
| 536 | 536 | }, |
| 537 | 537 | .NetworkShare => { |
| 538 | var it = mem.tokenize(u8, paths[first_index], "/\\"); | |
| 538 | var it = mem.tokenizeAny(u8, paths[first_index], "/\\"); | |
| 539 | 539 | const server_name = it.next().?; |
| 540 | 540 | const other_name = it.next().?; |
| 541 | 541 | |
| ... | ... | @@ -570,7 +570,7 @@ pub fn resolveWindows(allocator: Allocator, paths: []const []const u8) ![]u8 { |
| 570 | 570 | if (!correct_disk_designator) { |
| 571 | 571 | continue; |
| 572 | 572 | } |
| 573 | var it = mem.tokenize(u8, p[parsed.disk_designator.len..], "/\\"); | |
| 573 | var it = mem.tokenizeAny(u8, p[parsed.disk_designator.len..], "/\\"); | |
| 574 | 574 | while (it.next()) |component| { |
| 575 | 575 | if (mem.eql(u8, component, ".")) { |
| 576 | 576 | continue; |
| ... | ... | @@ -657,7 +657,7 @@ pub fn resolvePosix(allocator: Allocator, paths: []const []const u8) Allocator.E |
| 657 | 657 | negative_count = 0; |
| 658 | 658 | result.clearRetainingCapacity(); |
| 659 | 659 | } |
| 660 | var it = mem.tokenize(u8, p, "/"); | |
| 660 | var it = mem.tokenizeScalar(u8, p, '/'); | |
| 661 | 661 | while (it.next()) |component| { |
| 662 | 662 | if (mem.eql(u8, component, ".")) { |
| 663 | 663 | continue; |
| ... | ... | @@ -1078,8 +1078,8 @@ pub fn relativeWindows(allocator: Allocator, from: []const u8, to: []const u8) ! |
| 1078 | 1078 | return resolved_to; |
| 1079 | 1079 | } |
| 1080 | 1080 | |
| 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, "/\\"); | |
| 1083 | 1083 | while (true) { |
| 1084 | 1084 | const from_component = from_it.next() orelse return allocator.dupe(u8, to_it.rest()); |
| 1085 | 1085 | const to_rest = to_it.rest(); |
| ... | ... | @@ -1102,7 +1102,7 @@ pub fn relativeWindows(allocator: Allocator, from: []const u8, to: []const u8) ! |
| 1102 | 1102 | result_index += 3; |
| 1103 | 1103 | } |
| 1104 | 1104 | |
| 1105 | var rest_it = mem.tokenize(u8, to_rest, "/\\"); | |
| 1105 | var rest_it = mem.tokenizeAny(u8, to_rest, "/\\"); | |
| 1106 | 1106 | while (rest_it.next()) |to_component| { |
| 1107 | 1107 | result[result_index] = '\\'; |
| 1108 | 1108 | result_index += 1; |
| ... | ... | @@ -1124,8 +1124,8 @@ pub fn relativePosix(allocator: Allocator, from: []const u8, to: []const u8) ![] |
| 1124 | 1124 | const resolved_to = try resolvePosix(allocator, &[_][]const u8{ cwd, to }); |
| 1125 | 1125 | defer allocator.free(resolved_to); |
| 1126 | 1126 | |
| 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, '/'); | |
| 1129 | 1129 | while (true) { |
| 1130 | 1130 | const from_component = from_it.next() orelse return allocator.dupe(u8, to_it.rest()); |
| 1131 | 1131 | const to_rest = to_it.rest(); |
lib/std/http/Client.zig+2-2| ... | ... | @@ -386,7 +386,7 @@ pub const Response = struct { |
| 386 | 386 | }; |
| 387 | 387 | |
| 388 | 388 | 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"); | |
| 390 | 390 | |
| 391 | 391 | const first_line = it.next() orelse return error.HttpHeadersInvalid; |
| 392 | 392 | if (first_line.len < 12) |
| ... | ... | @@ -412,7 +412,7 @@ pub const Response = struct { |
| 412 | 412 | else => {}, |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | var line_it = mem.tokenize(u8, line, ": "); | |
| 415 | var line_it = mem.tokenizeAny(u8, line, ": "); | |
| 416 | 416 | const header_name = line_it.next() orelse return error.HttpHeadersInvalid; |
| 417 | 417 | const header_value = line_it.rest(); |
| 418 | 418 |
lib/std/http/Server.zig+2-2| ... | ... | @@ -231,7 +231,7 @@ pub const Request = struct { |
| 231 | 231 | }; |
| 232 | 232 | |
| 233 | 233 | 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"); | |
| 235 | 235 | |
| 236 | 236 | const first_line = it.next() orelse return error.HttpHeadersInvalid; |
| 237 | 237 | if (first_line.len < 10) |
| ... | ... | @@ -265,7 +265,7 @@ pub const Request = struct { |
| 265 | 265 | else => {}, |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | var line_it = mem.tokenize(u8, line, ": "); | |
| 268 | var line_it = mem.tokenizeAny(u8, line, ": "); | |
| 269 | 269 | const header_name = line_it.next() orelse return error.HttpHeadersInvalid; |
| 270 | 270 | const header_value = line_it.rest(); |
| 271 | 271 |
lib/std/net.zig+3-3| ... | ... | @@ -1266,7 +1266,7 @@ fn linuxLookupNameFromHosts( |
| 1266 | 1266 | var split_it = mem.split(u8, line, "#"); |
| 1267 | 1267 | const no_comment_line = split_it.first(); |
| 1268 | 1268 | |
| 1269 | var line_it = mem.tokenize(u8, no_comment_line, " \t"); | |
| 1269 | var line_it = mem.tokenizeAny(u8, no_comment_line, " \t"); | |
| 1270 | 1270 | const ip_text = line_it.next() orelse continue; |
| 1271 | 1271 | var first_name_text: ?[]const u8 = null; |
| 1272 | 1272 | while (line_it.next()) |name_text| { |
| ... | ... | @@ -1346,7 +1346,7 @@ fn linuxLookupNameFromDnsSearch( |
| 1346 | 1346 | @memcpy(canon.items, canon_name); |
| 1347 | 1347 | try canon.append('.'); |
| 1348 | 1348 | |
| 1349 | var tok_it = mem.tokenize(u8, search, " \t"); | |
| 1349 | var tok_it = mem.tokenizeAny(u8, search, " \t"); | |
| 1350 | 1350 | while (tok_it.next()) |tok| { |
| 1351 | 1351 | canon.shrinkRetainingCapacity(canon_name.len + 1); |
| 1352 | 1352 | try canon.appendSlice(tok); |
| ... | ... | @@ -1468,7 +1468,7 @@ fn getResolvConf(allocator: mem.Allocator, rc: *ResolvConf) !void { |
| 1468 | 1468 | var split = mem.split(u8, line, "#"); |
| 1469 | 1469 | break :no_comment_line split.first(); |
| 1470 | 1470 | }; |
| 1471 | var line_it = mem.tokenize(u8, no_comment_line, " \t"); | |
| 1471 | var line_it = mem.tokenizeAny(u8, no_comment_line, " \t"); | |
| 1472 | 1472 | |
| 1473 | 1473 | const token = line_it.next() orelse continue; |
| 1474 | 1474 | if (mem.eql(u8, token, "options")) { |
lib/std/os.zig+1-1| ... | ... | @@ -1878,7 +1878,7 @@ pub fn execvpeZ_expandArg0( |
| 1878 | 1878 | // Use of MAX_PATH_BYTES here is valid as the path_buf will be passed |
| 1879 | 1879 | // directly to the operating system in execveZ. |
| 1880 | 1880 | var path_buf: [MAX_PATH_BYTES]u8 = undefined; |
| 1881 | var it = mem.tokenize(u8, PATH, ":"); | |
| 1881 | var it = mem.tokenizeScalar(u8, PATH, ':'); | |
| 1882 | 1882 | var seen_eacces = false; |
| 1883 | 1883 | var err: ExecveError = error.FileNotFound; |
| 1884 | 1884 |
lib/std/process.zig+1-1| ... | ... | @@ -1200,7 +1200,7 @@ fn totalSystemMemoryLinux() !usize { |
| 1200 | 1200 | var buf: [50]u8 = undefined; |
| 1201 | 1201 | const amt = try file.read(&buf); |
| 1202 | 1202 | 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"); | |
| 1204 | 1204 | const label = it.next().?; |
| 1205 | 1205 | if (!std.mem.eql(u8, label, "MemTotal:")) return error.Unexpected; |
| 1206 | 1206 | 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 |
| 31 | 31 | defer allocator.free(nix_cflags_compile); |
| 32 | 32 | |
| 33 | 33 | is_nix = true; |
| 34 | var it = mem.tokenize(u8, nix_cflags_compile, " "); | |
| 34 | var it = mem.tokenizeScalar(u8, nix_cflags_compile, ' '); | |
| 35 | 35 | while (true) { |
| 36 | 36 | const word = it.next() orelse break; |
| 37 | 37 | if (mem.eql(u8, word, "-isystem")) { |
| ... | ... | @@ -62,7 +62,7 @@ pub fn detect(allocator: Allocator, native_info: NativeTargetInfo) !NativePaths |
| 62 | 62 | defer allocator.free(nix_ldflags); |
| 63 | 63 | |
| 64 | 64 | is_nix = true; |
| 65 | var it = mem.tokenize(u8, nix_ldflags, " "); | |
| 65 | var it = mem.tokenizeScalar(u8, nix_ldflags, ' '); | |
| 66 | 66 | while (true) { |
| 67 | 67 | const word = it.next() orelse break; |
| 68 | 68 | if (mem.eql(u8, word, "-rpath")) { |
| ... | ... | @@ -147,21 +147,21 @@ pub fn detect(allocator: Allocator, native_info: NativeTargetInfo) !NativePaths |
| 147 | 147 | // We use os.getenv here since this part won't be executed on |
| 148 | 148 | // windows, to get rid of unnecessary error handling. |
| 149 | 149 | 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, ':'); | |
| 151 | 151 | while (it.next()) |dir| { |
| 152 | 152 | try self.addIncludeDir(dir); |
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | 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, ':'); | |
| 158 | 158 | while (it.next()) |dir| { |
| 159 | 159 | try self.addIncludeDir(dir); |
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | if (std.os.getenv("LIBRARY_PATH")) |library_path| { |
| 164 | var it = mem.tokenize(u8, library_path, ":"); | |
| 164 | var it = mem.tokenizeScalar(u8, library_path, ':'); | |
| 165 | 165 | while (it.next()) |dir| { |
| 166 | 166 | try self.addLibDir(dir); |
| 167 | 167 | } |
lib/std/zig/system/NativeTargetInfo.zig+2-2| ... | ... | @@ -354,7 +354,7 @@ fn detectAbiAndDynamicLinker( |
| 354 | 354 | const newline = mem.indexOfScalar(u8, buffer[0..len], '\n') orelse break :blk file; |
| 355 | 355 | const line = buffer[0..newline]; |
| 356 | 356 | if (!mem.startsWith(u8, line, "#!")) break :blk file; |
| 357 | var it = mem.tokenize(u8, line[2..], " "); | |
| 357 | var it = mem.tokenizeScalar(u8, line[2..], ' '); | |
| 358 | 358 | file_name = it.next() orelse return defaultAbiAndDynamicLinker(cpu, os, cross_target); |
| 359 | 359 | file.close(); |
| 360 | 360 | } |
| ... | ... | @@ -811,7 +811,7 @@ pub fn abiAndDynamicLinkerFromFile( |
| 811 | 811 | const strtab = strtab_buf[0..strtab_read_len]; |
| 812 | 812 | |
| 813 | 813 | const rpath_list = mem.sliceTo(strtab, 0); |
| 814 | var it = mem.tokenize(u8, rpath_list, ":"); | |
| 814 | var it = mem.tokenizeScalar(u8, rpath_list, ':'); | |
| 815 | 815 | while (it.next()) |rpath| { |
| 816 | 816 | if (glibcVerFromRPath(rpath)) |ver| { |
| 817 | 817 | 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 { |
| 8409 | 8409 | } |
| 8410 | 8410 | |
| 8411 | 8411 | 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;"); | |
| 8413 | 8413 | while (line_it.next()) |line| { |
| 8414 | var mnem_it = mem.tokenize(u8, line, " \t"); | |
| 8414 | var mnem_it = mem.tokenizeAny(u8, line, " \t"); | |
| 8415 | 8415 | const mnem_str = mnem_it.next() orelse continue; |
| 8416 | 8416 | if (mem.startsWith(u8, mnem_str, "#")) continue; |
| 8417 | 8417 | |
| ... | ... | @@ -8435,7 +8435,7 @@ fn airAsm(self: *Self, inst: Air.Inst.Index) !void { |
| 8435 | 8435 | return self.fail("Invalid mnemonic: '{s}'", .{mnem_str}); |
| 8436 | 8436 | } }; |
| 8437 | 8437 | |
| 8438 | var op_it = mem.tokenize(u8, mnem_it.rest(), ","); | |
| 8438 | var op_it = mem.tokenizeScalar(u8, mnem_it.rest(), ','); | |
| 8439 | 8439 | var ops = [1]encoder.Instruction.Operand{.none} ** 4; |
| 8440 | 8440 | for (&ops) |*op| { |
| 8441 | 8441 | 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 |
| 109 | 109 | const target_name = mem.sliceTo(contents[index..], 0); |
| 110 | 110 | index += target_name.len + 1; |
| 111 | 111 | |
| 112 | var component_it = mem.tokenize(u8, target_name, "-"); | |
| 112 | var component_it = mem.tokenizeScalar(u8, target_name, '-'); | |
| 113 | 113 | const arch_name = component_it.next() orelse { |
| 114 | 114 | log.err("abilists: expected arch name", .{}); |
| 115 | 115 | return error.ZigInstallationCorrupt; |
src/libc_installation.zig+4-4| ... | ... | @@ -60,7 +60,7 @@ pub const LibCInstallation = struct { |
| 60 | 60 | const contents = try std.fs.cwd().readFileAlloc(allocator, libc_file, std.math.maxInt(usize)); |
| 61 | 61 | defer allocator.free(contents); |
| 62 | 62 | |
| 63 | var it = std.mem.tokenize(u8, contents, "\n"); | |
| 63 | var it = std.mem.tokenizeScalar(u8, contents, '\n'); | |
| 64 | 64 | while (it.next()) |line| { |
| 65 | 65 | if (line.len == 0 or line[0] == '#') continue; |
| 66 | 66 | var line_it = std.mem.split(u8, line, "="); |
| ... | ... | @@ -293,7 +293,7 @@ pub const LibCInstallation = struct { |
| 293 | 293 | }, |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | var it = std.mem.tokenize(u8, exec_res.stderr, "\n\r"); | |
| 296 | var it = std.mem.tokenizeAny(u8, exec_res.stderr, "\n\r"); | |
| 297 | 297 | var search_paths = std.ArrayList([]const u8).init(allocator); |
| 298 | 298 | defer search_paths.deinit(); |
| 299 | 299 | while (it.next()) |line| { |
| ... | ... | @@ -613,7 +613,7 @@ fn ccPrintFileName(args: CCPrintFileNameOptions) ![:0]u8 { |
| 613 | 613 | }, |
| 614 | 614 | } |
| 615 | 615 | |
| 616 | var it = std.mem.tokenize(u8, exec_res.stdout, "\n\r"); | |
| 616 | var it = std.mem.tokenizeAny(u8, exec_res.stdout, "\n\r"); | |
| 617 | 617 | const line = it.next() orelse return error.LibCRuntimeNotFound; |
| 618 | 618 | // When this command fails, it returns exit code 0 and duplicates the input file name. |
| 619 | 619 | // 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 { |
| 692 | 692 | return; |
| 693 | 693 | }; |
| 694 | 694 | // 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, ' '); | |
| 696 | 696 | while (it.next()) |arg| { |
| 697 | 697 | try args.append(arg); |
| 698 | 698 | } |
src/link/Plan9.zig+1-1| ... | ... | @@ -264,7 +264,7 @@ fn putFn(self: *Plan9, decl_index: Module.Decl.Index, out: FnDeclOutput) !void { |
| 264 | 264 | |
| 265 | 265 | fn addPathComponents(self: *Plan9, path: []const u8, a: *std.ArrayList(u8)) !void { |
| 266 | 266 | const sep = std.fs.path.sep; |
| 267 | var it = std.mem.tokenize(u8, path, &.{sep}); | |
| 267 | var it = std.mem.tokenizeScalar(u8, path, sep); | |
| 268 | 268 | while (it.next()) |component| { |
| 269 | 269 | if (self.file_segments.get(component)) |num| { |
| 270 | 270 | try a.writer().writeIntBig(u16, num); |
src/print_zir.zig+1-1| ... | ... | @@ -2581,7 +2581,7 @@ const Writer = struct { |
| 2581 | 2581 | fn writeDocComment(self: *Writer, stream: anytype, doc_comment_index: u32) !void { |
| 2582 | 2582 | if (doc_comment_index != 0) { |
| 2583 | 2583 | 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'); | |
| 2585 | 2585 | while (it.next()) |doc_line| { |
| 2586 | 2586 | try stream.writeByteNTimes(' ', self.indent); |
| 2587 | 2587 | try stream.print("///{s}\n", .{doc_line}); |
test/behavior/bugs/6456.zig+1-1| ... | ... | @@ -18,7 +18,7 @@ test "issue 6456" { |
| 18 | 18 | comptime { |
| 19 | 19 | var fields: []const StructField = &[0]StructField{}; |
| 20 | 20 | |
| 21 | var it = std.mem.tokenize(u8, text, "\n"); | |
| 21 | var it = std.mem.tokenizeScalar(u8, text, '\n'); | |
| 22 | 22 | while (it.next()) |name| { |
| 23 | 23 | fields = fields ++ &[_]StructField{StructField{ |
| 24 | 24 | .alignment = 0, |
test/src/Cases.zig+2-2| ... | ... | @@ -846,7 +846,7 @@ const TestManifest = struct { |
| 846 | 846 | const actual_start = start orelse return error.MissingTestManifest; |
| 847 | 847 | const manifest_bytes = bytes[actual_start..end]; |
| 848 | 848 | |
| 849 | var it = std.mem.tokenize(u8, manifest_bytes, "\r\n"); | |
| 849 | var it = std.mem.tokenizeAny(u8, manifest_bytes, "\r\n"); | |
| 850 | 850 | |
| 851 | 851 | // First line is the test type |
| 852 | 852 | const tt: Type = blk: { |
| ... | ... | @@ -923,7 +923,7 @@ const TestManifest = struct { |
| 923 | 923 | |
| 924 | 924 | fn trailing(self: TestManifest) TrailingIterator { |
| 925 | 925 | return .{ |
| 926 | .inner = std.mem.tokenize(u8, self.trailing_bytes, "\r\n"), | |
| 926 | .inner = std.mem.tokenizeAny(u8, self.trailing_bytes, "\r\n"), | |
| 927 | 927 | }; |
| 928 | 928 | } |
| 929 | 929 |
tools/generate_linux_syscalls.zig+18-18| ... | ... | @@ -51,11 +51,11 @@ pub fn main() !void { |
| 51 | 51 | try writer.writeAll("pub const X86 = enum(usize) {\n"); |
| 52 | 52 | |
| 53 | 53 | 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'); | |
| 55 | 55 | while (lines.next()) |line| { |
| 56 | 56 | if (line[0] == '#') continue; |
| 57 | 57 | |
| 58 | var fields = mem.tokenize(u8, line, " \t"); | |
| 58 | var fields = mem.tokenizeAny(u8, line, " \t"); | |
| 59 | 59 | const number = fields.next() orelse return error.Incomplete; |
| 60 | 60 | // abi is always i386 |
| 61 | 61 | _ = fields.next() orelse return error.Incomplete; |
| ... | ... | @@ -70,11 +70,11 @@ pub fn main() !void { |
| 70 | 70 | try writer.writeAll("pub const X64 = enum(usize) {\n"); |
| 71 | 71 | |
| 72 | 72 | 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'); | |
| 74 | 74 | while (lines.next()) |line| { |
| 75 | 75 | if (line[0] == '#') continue; |
| 76 | 76 | |
| 77 | var fields = mem.tokenize(u8, line, " \t"); | |
| 77 | var fields = mem.tokenizeAny(u8, line, " \t"); | |
| 78 | 78 | const number = fields.next() orelse return error.Incomplete; |
| 79 | 79 | const abi = fields.next() orelse return error.Incomplete; |
| 80 | 80 | // The x32 abi syscalls are always at the end. |
| ... | ... | @@ -96,11 +96,11 @@ pub fn main() !void { |
| 96 | 96 | ); |
| 97 | 97 | |
| 98 | 98 | 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'); | |
| 100 | 100 | while (lines.next()) |line| { |
| 101 | 101 | if (line[0] == '#') continue; |
| 102 | 102 | |
| 103 | var fields = mem.tokenize(u8, line, " \t"); | |
| 103 | var fields = mem.tokenizeAny(u8, line, " \t"); | |
| 104 | 104 | const number = fields.next() orelse return error.Incomplete; |
| 105 | 105 | const abi = fields.next() orelse return error.Incomplete; |
| 106 | 106 | if (mem.eql(u8, abi, "oabi")) continue; |
| ... | ... | @@ -127,11 +127,11 @@ pub fn main() !void { |
| 127 | 127 | { |
| 128 | 128 | try writer.writeAll("pub const Sparc64 = enum(usize) {\n"); |
| 129 | 129 | 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'); | |
| 131 | 131 | while (lines.next()) |line| { |
| 132 | 132 | if (line[0] == '#') continue; |
| 133 | 133 | |
| 134 | var fields = mem.tokenize(u8, line, " \t"); | |
| 134 | var fields = mem.tokenizeAny(u8, line, " \t"); | |
| 135 | 135 | const number = fields.next() orelse return error.Incomplete; |
| 136 | 136 | const abi = fields.next() orelse return error.Incomplete; |
| 137 | 137 | if (mem.eql(u8, abi, "32")) continue; |
| ... | ... | @@ -151,11 +151,11 @@ pub fn main() !void { |
| 151 | 151 | ); |
| 152 | 152 | |
| 153 | 153 | 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'); | |
| 155 | 155 | while (lines.next()) |line| { |
| 156 | 156 | if (line[0] == '#') continue; |
| 157 | 157 | |
| 158 | var fields = mem.tokenize(u8, line, " \t"); | |
| 158 | var fields = mem.tokenizeAny(u8, line, " \t"); | |
| 159 | 159 | const number = fields.next() orelse return error.Incomplete; |
| 160 | 160 | // abi is always o32 |
| 161 | 161 | _ = fields.next() orelse return error.Incomplete; |
| ... | ... | @@ -176,11 +176,11 @@ pub fn main() !void { |
| 176 | 176 | ); |
| 177 | 177 | |
| 178 | 178 | 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'); | |
| 180 | 180 | while (lines.next()) |line| { |
| 181 | 181 | if (line[0] == '#') continue; |
| 182 | 182 | |
| 183 | var fields = mem.tokenize(u8, line, " \t"); | |
| 183 | var fields = mem.tokenizeAny(u8, line, " \t"); | |
| 184 | 184 | const number = fields.next() orelse return error.Incomplete; |
| 185 | 185 | // abi is always n64 |
| 186 | 186 | _ = fields.next() orelse return error.Incomplete; |
| ... | ... | @@ -197,11 +197,11 @@ pub fn main() !void { |
| 197 | 197 | |
| 198 | 198 | const table = try linux_dir.readFile("arch/powerpc/kernel/syscalls/syscall.tbl", buf); |
| 199 | 199 | var list_64 = std.ArrayList(u8).init(allocator); |
| 200 | var lines = mem.tokenize(u8, table, "\n"); | |
| 200 | var lines = mem.tokenizeScalar(u8, table, '\n'); | |
| 201 | 201 | while (lines.next()) |line| { |
| 202 | 202 | if (line[0] == '#') continue; |
| 203 | 203 | |
| 204 | var fields = mem.tokenize(u8, line, " \t"); | |
| 204 | var fields = mem.tokenizeAny(u8, line, " \t"); | |
| 205 | 205 | const number = fields.next() orelse return error.Incomplete; |
| 206 | 206 | const abi = fields.next() orelse return error.Incomplete; |
| 207 | 207 | const name = fields.next() orelse return error.Incomplete; |
| ... | ... | @@ -277,9 +277,9 @@ pub fn main() !void { |
| 277 | 277 | }, |
| 278 | 278 | }; |
| 279 | 279 | |
| 280 | var lines = mem.tokenize(u8, defines, "\n"); | |
| 280 | var lines = mem.tokenizeScalar(u8, defines, '\n'); | |
| 281 | 281 | loop: while (lines.next()) |line| { |
| 282 | var fields = mem.tokenize(u8, line, " \t"); | |
| 282 | var fields = mem.tokenizeAny(u8, line, " \t"); | |
| 283 | 283 | const cmd = fields.next() orelse return error.Incomplete; |
| 284 | 284 | if (!mem.eql(u8, cmd, "#define")) continue; |
| 285 | 285 | const define = fields.next() orelse return error.Incomplete; |
| ... | ... | @@ -339,9 +339,9 @@ pub fn main() !void { |
| 339 | 339 | }, |
| 340 | 340 | }; |
| 341 | 341 | |
| 342 | var lines = mem.tokenize(u8, defines, "\n"); | |
| 342 | var lines = mem.tokenizeScalar(u8, defines, '\n'); | |
| 343 | 343 | loop: while (lines.next()) |line| { |
| 344 | var fields = mem.tokenize(u8, line, " \t"); | |
| 344 | var fields = mem.tokenizeAny(u8, line, " \t"); | |
| 345 | 345 | const cmd = fields.next() orelse return error.Incomplete; |
| 346 | 346 | if (!mem.eql(u8, cmd, "#define")) continue; |
| 347 | 347 | const define = fields.next() orelse return error.Incomplete; |