authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2023-05-04 18:15:50-07:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2023-05-13 13:45:05-07:00
log2129f28953b72da2f1bb58ff063a044d737c59c4
treed8b12c947b4936cd96f753537c6effd36b2cb0c2
parent815e53b147a321d0bdb47dc008aa8181f57175ac

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

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

27 files changed, 58 insertions(+), 55 deletions(-)

build.zig+3-3
...@@ -239,7 +239,7 @@ pub fn build(b: *std.Build) !void {...@@ -239,7 +239,7 @@ pub fn build(b: *std.Build) !void {
239 },239 },
240 2 => {240 2 => {
241 // Untagged development build (e.g. 0.10.0-dev.2025+ecf0050a9).241 // Untagged development build (e.g. 0.10.0-dev.2025+ecf0050a9).
242 var it = mem.split(u8, git_describe, "-");242 var it = mem.splitScalar(u8, git_describe, '-');
243 const tagged_ancestor = it.first();243 const tagged_ancestor = it.first();
244 const commit_height = it.next().?;244 const commit_height = it.next().?;
245 const commit_id = it.next().?;245 const commit_id = it.next().?;
...@@ -859,14 +859,14 @@ fn parseConfigH(b: *std.Build, config_h_text: []const u8) ?CMakeConfig {...@@ -859,14 +859,14 @@ fn parseConfigH(b: *std.Build, config_h_text: []const u8) ?CMakeConfig {
859 while (lines_it.next()) |line| {859 while (lines_it.next()) |line| {
860 inline for (mappings) |mapping| {860 inline for (mappings) |mapping| {
861 if (mem.startsWith(u8, line, mapping.prefix)) {861 if (mem.startsWith(u8, line, mapping.prefix)) {
862 var it = mem.split(u8, line, "\"");862 var it = mem.splitScalar(u8, line, '"');
863 _ = it.first(); // skip the stuff before the quote863 _ = it.first(); // skip the stuff before the quote
864 const quoted = it.next().?; // the stuff inside the quote864 const quoted = it.next().?; // the stuff inside the quote
865 @field(ctx, mapping.field) = toNativePathSep(b, quoted);865 @field(ctx, mapping.field) = toNativePathSep(b, quoted);
866 }866 }
867 }867 }
868 if (mem.startsWith(u8, line, "#define ZIG_LLVM_LINK_MODE ")) {868 if (mem.startsWith(u8, line, "#define ZIG_LLVM_LINK_MODE ")) {
869 var it = mem.split(u8, line, "\"");869 var it = mem.splitScalar(u8, line, '"');
870 _ = it.next().?; // skip the stuff before the quote870 _ = it.next().?; // skip the stuff before the quote
871 const quoted = it.next().?; // the stuff inside the quote871 const quoted = it.next().?; // the stuff inside the quote
872 ctx.llvm_linkage = if (mem.eql(u8, quoted, "shared")) .dynamic else .static;872 ctx.llvm_linkage = if (mem.eql(u8, quoted, "shared")) .dynamic else .static;
doc/docgen.zig+1-1
...@@ -1223,7 +1223,7 @@ fn printShell(out: anytype, shell_content: []const u8, escape: bool) !void {...@@ -1223,7 +1223,7 @@ fn printShell(out: anytype, shell_content: []const u8, escape: bool) !void {
1223 const trimmed_shell_content = mem.trim(u8, shell_content, " \n");1223 const trimmed_shell_content = mem.trim(u8, shell_content, " \n");
1224 try out.writeAll("<figure><figcaption class=\"shell-cap\">Shell</figcaption><pre><samp>");1224 try out.writeAll("<figure><figcaption class=\"shell-cap\">Shell</figcaption><pre><samp>");
1225 var cmd_cont: bool = false;1225 var cmd_cont: bool = false;
1226 var iter = std.mem.split(u8, trimmed_shell_content, "\n");1226 var iter = std.mem.splitScalar(u8, trimmed_shell_content, '\n');
1227 while (iter.next()) |orig_line| {1227 while (iter.next()) |orig_line| {
1228 const line = mem.trimRight(u8, orig_line, " ");1228 const line = mem.trimRight(u8, orig_line, " ");
1229 if (!cmd_cont and line.len > 1 and mem.eql(u8, line[0..2], "$ ") and line[line.len - 1] != '\\') {1229 if (!cmd_cont and line.len > 1 and mem.eql(u8, line[0..2], "$ ") and line[line.len - 1] != '\\') {
lib/std/Build/Step/Compile.zig+1-1
...@@ -2140,7 +2140,7 @@ fn checkCompileErrors(self: *Compile) !void {...@@ -2140,7 +2140,7 @@ fn checkCompileErrors(self: *Compile) !void {
2140 // Render the expected lines into a string that we can compare verbatim.2140 // Render the expected lines into a string that we can compare verbatim.
2141 var expected_generated = std.ArrayList(u8).init(arena);2141 var expected_generated = std.ArrayList(u8).init(arena);
21422142
2143 var actual_line_it = mem.split(u8, actual_stderr, "\n");2143 var actual_line_it = mem.splitScalar(u8, actual_stderr, '\n');
2144 for (self.expect_errors) |expect_line| {2144 for (self.expect_errors) |expect_line| {
2145 const actual_line = actual_line_it.next() orelse {2145 const actual_line = actual_line_it.next() orelse {
2146 try expected_generated.appendSlice(expect_line);2146 try expected_generated.appendSlice(expect_line);
lib/std/Build/Step/ConfigHeader.zig+2-2
...@@ -250,7 +250,7 @@ fn render_autoconf(...@@ -250,7 +250,7 @@ fn render_autoconf(
250250
251 var any_errors = false;251 var any_errors = false;
252 var line_index: u32 = 0;252 var line_index: u32 = 0;
253 var line_it = std.mem.split(u8, contents, "\n");253 var line_it = std.mem.splitScalar(u8, contents, '\n');
254 while (line_it.next()) |line| : (line_index += 1) {254 while (line_it.next()) |line| : (line_index += 1) {
255 if (!std.mem.startsWith(u8, line, "#")) {255 if (!std.mem.startsWith(u8, line, "#")) {
256 try output.appendSlice(line);256 try output.appendSlice(line);
...@@ -297,7 +297,7 @@ fn render_cmake(...@@ -297,7 +297,7 @@ fn render_cmake(
297297
298 var any_errors = false;298 var any_errors = false;
299 var line_index: u32 = 0;299 var line_index: u32 = 0;
300 var line_it = std.mem.split(u8, contents, "\n");300 var line_it = std.mem.splitScalar(u8, contents, '\n');
301 while (line_it.next()) |line| : (line_index += 1) {301 while (line_it.next()) |line| : (line_index += 1) {
302 if (!std.mem.startsWith(u8, line, "#")) {302 if (!std.mem.startsWith(u8, line, "#")) {
303 try output.appendSlice(line);303 try output.appendSlice(line);
lib/std/SemanticVersion.zig+5-5
...@@ -42,8 +42,8 @@ pub fn order(lhs: Version, rhs: Version) std.math.Order {...@@ -42,8 +42,8 @@ pub fn order(lhs: Version, rhs: Version) std.math.Order {
42 if (lhs.pre == null and rhs.pre != null) return .gt;42 if (lhs.pre == null and rhs.pre != null) return .gt;
4343
44 // Iterate over pre-release identifiers until a difference is found.44 // Iterate over pre-release identifiers until a difference is found.
45 var lhs_pre_it = std.mem.split(u8, lhs.pre.?, ".");45 var lhs_pre_it = std.mem.splitScalar(u8, lhs.pre.?, '.');
46 var rhs_pre_it = std.mem.split(u8, rhs.pre.?, ".");46 var rhs_pre_it = std.mem.splitScalar(u8, rhs.pre.?, '.');
47 while (true) {47 while (true) {
48 const next_lid = lhs_pre_it.next();48 const next_lid = lhs_pre_it.next();
49 const next_rid = rhs_pre_it.next();49 const next_rid = rhs_pre_it.next();
...@@ -86,7 +86,7 @@ pub fn parse(text: []const u8) !Version {...@@ -86,7 +86,7 @@ pub fn parse(text: []const u8) !Version {
86 // Parse the required major, minor, and patch numbers.86 // Parse the required major, minor, and patch numbers.
87 const extra_index = std.mem.indexOfAny(u8, text, "-+");87 const extra_index = std.mem.indexOfAny(u8, text, "-+");
88 const required = text[0..(extra_index orelse text.len)];88 const required = text[0..(extra_index orelse text.len)];
89 var it = std.mem.split(u8, required, ".");89 var it = std.mem.splitScalar(u8, required, '.');
90 var ver = Version{90 var ver = Version{
91 .major = try parseNum(it.first()),91 .major = try parseNum(it.first()),
92 .minor = try parseNum(it.next() orelse return error.InvalidVersion),92 .minor = try parseNum(it.next() orelse return error.InvalidVersion),
...@@ -108,7 +108,7 @@ pub fn parse(text: []const u8) !Version {...@@ -108,7 +108,7 @@ pub fn parse(text: []const u8) !Version {
108 // Check validity of optional pre-release identifiers.108 // Check validity of optional pre-release identifiers.
109 // See: https://semver.org/#spec-item-9109 // See: https://semver.org/#spec-item-9
110 if (ver.pre) |pre| {110 if (ver.pre) |pre| {
111 it = std.mem.split(u8, pre, ".");111 it = std.mem.splitScalar(u8, pre, '.');
112 while (it.next()) |id| {112 while (it.next()) |id| {
113 // Identifiers MUST NOT be empty.113 // Identifiers MUST NOT be empty.
114 if (id.len == 0) return error.InvalidVersion;114 if (id.len == 0) return error.InvalidVersion;
...@@ -127,7 +127,7 @@ pub fn parse(text: []const u8) !Version {...@@ -127,7 +127,7 @@ pub fn parse(text: []const u8) !Version {
127 // Check validity of optional build metadata identifiers.127 // Check validity of optional build metadata identifiers.
128 // See: https://semver.org/#spec-item-10128 // See: https://semver.org/#spec-item-10
129 if (ver.build) |build| {129 if (ver.build) |build| {
130 it = std.mem.split(u8, build, ".");130 it = std.mem.splitScalar(u8, build, '.');
131 while (it.next()) |id| {131 while (it.next()) |id| {
132 // Identifiers MUST NOT be empty.132 // Identifiers MUST NOT be empty.
133 if (id.len == 0) return error.InvalidVersion;133 if (id.len == 0) return error.InvalidVersion;
lib/std/builtin.zig+1-1
...@@ -531,7 +531,7 @@ pub const Version = struct {...@@ -531,7 +531,7 @@ pub const Version = struct {
531 // found no digits or '.' before unexpected character531 // found no digits or '.' before unexpected character
532 if (end == 0) return error.InvalidVersion;532 if (end == 0) return error.InvalidVersion;
533533
534 var it = std.mem.split(u8, text[0..end], ".");534 var it = std.mem.splitScalar(u8, text[0..end], '.');
535 // substring is not empty, first call will succeed535 // substring is not empty, first call will succeed
536 const major = it.first();536 const major = it.first();
537 if (major.len == 0) return error.InvalidVersion;537 if (major.len == 0) return error.InvalidVersion;
lib/std/crypto/Certificate.zig+2-2
...@@ -337,8 +337,8 @@ pub const Parsed = struct {...@@ -337,8 +337,8 @@ pub const Parsed = struct {
337 return true; // exact match337 return true; // exact match
338 }338 }
339339
340 var it_host = std.mem.split(u8, host_name, ".");340 var it_host = std.mem.splitScalar(u8, host_name, '.');
341 var it_dns = std.mem.split(u8, dns_name, ".");341 var it_dns = std.mem.splitScalar(u8, dns_name, '.');
342342
343 const len_match = while (true) {343 const len_match = while (true) {
344 const host = it_host.next();344 const host = it_host.next();
lib/std/crypto/phc_encoding.zig+6-3
...@@ -7,9 +7,12 @@ const mem = std.mem;...@@ -7,9 +7,12 @@ const mem = std.mem;
7const meta = std.meta;7const meta = std.meta;
88
9const fields_delimiter = "$";9const fields_delimiter = "$";
10const fields_delimiter_scalar = '$';
10const version_param_name = "v";11const version_param_name = "v";
11const params_delimiter = ",";12const params_delimiter = ",";
13const params_delimiter_scalar = ',';
12const kv_delimiter = "=";14const kv_delimiter = "=";
15const kv_delimiter_scalar = '=';
1316
14pub const Error = std.crypto.errors.EncodingError || error{NoSpaceLeft};17pub const Error = std.crypto.errors.EncodingError || error{NoSpaceLeft};
1518
...@@ -73,7 +76,7 @@ pub fn BinValue(comptime max_len: usize) type {...@@ -73,7 +76,7 @@ pub fn BinValue(comptime max_len: usize) type {
73/// Other fields will also be deserialized from the function parameters section.76/// Other fields will also be deserialized from the function parameters section.
74pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult {77pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult {
75 var out = mem.zeroes(HashResult);78 var out = mem.zeroes(HashResult);
76 var it = mem.split(u8, str, fields_delimiter);79 var it = mem.splitScalar(u8, str, fields_delimiter_scalar);
77 var set_fields: usize = 0;80 var set_fields: usize = 0;
7881
79 while (true) {82 while (true) {
...@@ -104,7 +107,7 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult...@@ -104,7 +107,7 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult
104107
105 // Read optional parameters108 // Read optional parameters
106 var has_params = false;109 var has_params = false;
107 var it_params = mem.split(u8, field, params_delimiter);110 var it_params = mem.splitScalar(u8, field, params_delimiter_scalar);
108 while (it_params.next()) |params| {111 while (it_params.next()) |params| {
109 const param = kvSplit(params) catch break;112 const param = kvSplit(params) catch break;
110 var found = false;113 var found = false;
...@@ -252,7 +255,7 @@ fn serializeTo(params: anytype, out: anytype) !void {...@@ -252,7 +255,7 @@ fn serializeTo(params: anytype, out: anytype) !void {
252255
253// Split a `key=value` string into `key` and `value`256// Split a `key=value` string into `key` and `value`
254fn kvSplit(str: []const u8) !struct { key: []const u8, value: []const u8 } {257fn kvSplit(str: []const u8) !struct { key: []const u8, value: []const u8 } {
255 var it = mem.split(u8, str, kv_delimiter);258 var it = mem.splitScalar(u8, str, kv_delimiter_scalar);
256 const key = it.first();259 const key = it.first();
257 const value = it.next() orelse return Error.InvalidEncoding;260 const value = it.next() orelse return Error.InvalidEncoding;
258 const ret = .{ .key = key, .value = value };261 const ret = .{ .key = key, .value = value };
lib/std/crypto/scrypt.zig+1-1
...@@ -287,7 +287,7 @@ const crypt_format = struct {...@@ -287,7 +287,7 @@ const crypt_format = struct {
287 out.r = try Codec.intDecode(u30, str[4..9]);287 out.r = try Codec.intDecode(u30, str[4..9]);
288 out.p = try Codec.intDecode(u30, str[9..14]);288 out.p = try Codec.intDecode(u30, str[9..14]);
289289
290 var it = mem.split(u8, str[14..], "$");290 var it = mem.splitScalar(u8, str[14..], '$');
291291
292 const salt = it.first();292 const salt = it.first();
293 if (@hasField(T, "salt")) out.salt = salt;293 if (@hasField(T, "salt")) out.salt = salt;
lib/std/http/Client.zig+1-1
...@@ -426,7 +426,7 @@ pub const Response = struct {...@@ -426,7 +426,7 @@ pub const Response = struct {
426 } else if (std.ascii.eqlIgnoreCase(header_name, "transfer-encoding")) {426 } else if (std.ascii.eqlIgnoreCase(header_name, "transfer-encoding")) {
427 // Transfer-Encoding: second, first427 // Transfer-Encoding: second, first
428 // Transfer-Encoding: deflate, chunked428 // Transfer-Encoding: deflate, chunked
429 var iter = mem.splitBackwards(u8, header_value, ",");429 var iter = mem.splitBackwardsScalar(u8, header_value, ',');
430430
431 if (iter.next()) |first| {431 if (iter.next()) |first| {
432 const trimmed = mem.trim(u8, first, " ");432 const trimmed = mem.trim(u8, first, " ");
lib/std/http/Server.zig+1-1
...@@ -277,7 +277,7 @@ pub const Request = struct {...@@ -277,7 +277,7 @@ pub const Request = struct {
277 } else if (std.ascii.eqlIgnoreCase(header_name, "transfer-encoding")) {277 } else if (std.ascii.eqlIgnoreCase(header_name, "transfer-encoding")) {
278 // Transfer-Encoding: second, first278 // Transfer-Encoding: second, first
279 // Transfer-Encoding: deflate, chunked279 // Transfer-Encoding: deflate, chunked
280 var iter = mem.splitBackwards(u8, header_value, ",");280 var iter = mem.splitBackwardsScalar(u8, header_value, ',');
281281
282 if (iter.next()) |first| {282 if (iter.next()) |first| {
283 const trimmed = mem.trim(u8, first, " ");283 const trimmed = mem.trim(u8, first, " ");
lib/std/net.zig+3-3
...@@ -1263,7 +1263,7 @@ fn linuxLookupNameFromHosts(...@@ -1263,7 +1263,7 @@ fn linuxLookupNameFromHosts(
1263 },1263 },
1264 else => |e| return e,1264 else => |e| return e,
1265 }) |line| {1265 }) |line| {
1266 var split_it = mem.split(u8, line, "#");1266 var split_it = mem.splitScalar(u8, line, '#');
1267 const no_comment_line = split_it.first();1267 const no_comment_line = split_it.first();
12681268
1269 var line_it = mem.tokenizeAny(u8, no_comment_line, " \t");1269 var line_it = mem.tokenizeAny(u8, no_comment_line, " \t");
...@@ -1465,7 +1465,7 @@ fn getResolvConf(allocator: mem.Allocator, rc: *ResolvConf) !void {...@@ -1465,7 +1465,7 @@ fn getResolvConf(allocator: mem.Allocator, rc: *ResolvConf) !void {
1465 else => |e| return e,1465 else => |e| return e,
1466 }) |line| {1466 }) |line| {
1467 const no_comment_line = no_comment_line: {1467 const no_comment_line = no_comment_line: {
1468 var split = mem.split(u8, line, "#");1468 var split = mem.splitScalar(u8, line, '#');
1469 break :no_comment_line split.first();1469 break :no_comment_line split.first();
1470 };1470 };
1471 var line_it = mem.tokenizeAny(u8, no_comment_line, " \t");1471 var line_it = mem.tokenizeAny(u8, no_comment_line, " \t");
...@@ -1473,7 +1473,7 @@ fn getResolvConf(allocator: mem.Allocator, rc: *ResolvConf) !void {...@@ -1473,7 +1473,7 @@ fn getResolvConf(allocator: mem.Allocator, rc: *ResolvConf) !void {
1473 const token = line_it.next() orelse continue;1473 const token = line_it.next() orelse continue;
1474 if (mem.eql(u8, token, "options")) {1474 if (mem.eql(u8, token, "options")) {
1475 while (line_it.next()) |sub_tok| {1475 while (line_it.next()) |sub_tok| {
1476 var colon_it = mem.split(u8, sub_tok, ":");1476 var colon_it = mem.splitScalar(u8, sub_tok, ':');
1477 const name = colon_it.first();1477 const name = colon_it.first();
1478 const value_txt = colon_it.next() orelse continue;1478 const value_txt = colon_it.next() orelse continue;
1479 const value = std.fmt.parseInt(u8, value_txt, 10) catch |err| switch (err) {1479 const value = std.fmt.parseInt(u8, value_txt, 10) catch |err| switch (err) {
lib/std/process.zig+1-1
...@@ -310,7 +310,7 @@ pub fn getEnvMap(allocator: Allocator) !EnvMap {...@@ -310,7 +310,7 @@ pub fn getEnvMap(allocator: Allocator) !EnvMap {
310310
311 for (environ) |env| {311 for (environ) |env| {
312 const pair = mem.sliceTo(env, 0);312 const pair = mem.sliceTo(env, 0);
313 var parts = mem.split(u8, pair, "=");313 var parts = mem.splitScalar(u8, pair, '=');
314 const key = parts.first();314 const key = parts.first();
315 const value = parts.rest();315 const value = parts.rest();
316 try result.put(key, value);316 try result.put(key, value);
lib/std/zig/CrossTarget.zig+6-6
...@@ -239,7 +239,7 @@ pub fn parse(args: ParseOptions) !CrossTarget {...@@ -239,7 +239,7 @@ pub fn parse(args: ParseOptions) !CrossTarget {
239 .dynamic_linker = DynamicLinker.init(args.dynamic_linker),239 .dynamic_linker = DynamicLinker.init(args.dynamic_linker),
240 };240 };
241241
242 var it = mem.split(u8, args.arch_os_abi, "-");242 var it = mem.splitScalar(u8, args.arch_os_abi, '-');
243 const arch_name = it.first();243 const arch_name = it.first();
244 const arch_is_native = mem.eql(u8, arch_name, "native");244 const arch_is_native = mem.eql(u8, arch_name, "native");
245 if (!arch_is_native) {245 if (!arch_is_native) {
...@@ -257,7 +257,7 @@ pub fn parse(args: ParseOptions) !CrossTarget {...@@ -257,7 +257,7 @@ pub fn parse(args: ParseOptions) !CrossTarget {
257257
258 const opt_abi_text = it.next();258 const opt_abi_text = it.next();
259 if (opt_abi_text) |abi_text| {259 if (opt_abi_text) |abi_text| {
260 var abi_it = mem.split(u8, abi_text, ".");260 var abi_it = mem.splitScalar(u8, abi_text, '.');
261 const abi = std.meta.stringToEnum(Target.Abi, abi_it.first()) orelse261 const abi = std.meta.stringToEnum(Target.Abi, abi_it.first()) orelse
262 return error.UnknownApplicationBinaryInterface;262 return error.UnknownApplicationBinaryInterface;
263 result.abi = abi;263 result.abi = abi;
...@@ -343,7 +343,7 @@ pub fn parse(args: ParseOptions) !CrossTarget {...@@ -343,7 +343,7 @@ pub fn parse(args: ParseOptions) !CrossTarget {
343/// This is intended to be used if the API user of CrossTarget needs to learn the343/// This is intended to be used if the API user of CrossTarget needs to learn the
344/// target CPU architecture in order to fully populate `ParseOptions`.344/// target CPU architecture in order to fully populate `ParseOptions`.
345pub fn parseCpuArch(args: ParseOptions) ?Target.Cpu.Arch {345pub fn parseCpuArch(args: ParseOptions) ?Target.Cpu.Arch {
346 var it = mem.split(u8, args.arch_os_abi, "-");346 var it = mem.splitScalar(u8, args.arch_os_abi, '-');
347 const arch_name = it.first();347 const arch_name = it.first();
348 const arch_is_native = mem.eql(u8, arch_name, "native");348 const arch_is_native = mem.eql(u8, arch_name, "native");
349 if (arch_is_native) {349 if (arch_is_native) {
...@@ -645,7 +645,7 @@ pub fn updateCpuFeatures(self: CrossTarget, set: *Target.Cpu.Feature.Set) void {...@@ -645,7 +645,7 @@ pub fn updateCpuFeatures(self: CrossTarget, set: *Target.Cpu.Feature.Set) void {
645}645}
646646
647fn parseOs(result: *CrossTarget, diags: *ParseOptions.Diagnostics, text: []const u8) !void {647fn parseOs(result: *CrossTarget, diags: *ParseOptions.Diagnostics, text: []const u8) !void {
648 var it = mem.split(u8, text, ".");648 var it = mem.splitScalar(u8, text, '.');
649 const os_name = it.first();649 const os_name = it.first();
650 diags.os_name = os_name;650 diags.os_name = os_name;
651 const os_is_native = mem.eql(u8, os_name, "native");651 const os_is_native = mem.eql(u8, os_name, "native");
...@@ -706,7 +706,7 @@ fn parseOs(result: *CrossTarget, diags: *ParseOptions.Diagnostics, text: []const...@@ -706,7 +706,7 @@ fn parseOs(result: *CrossTarget, diags: *ParseOptions.Diagnostics, text: []const
706 .linux,706 .linux,
707 .dragonfly,707 .dragonfly,
708 => {708 => {
709 var range_it = mem.split(u8, version_text, "...");709 var range_it = mem.splitFull(u8, version_text, "...");
710710
711 const min_text = range_it.next().?;711 const min_text = range_it.next().?;
712 const min_ver = SemVer.parse(min_text) catch |err| switch (err) {712 const min_ver = SemVer.parse(min_text) catch |err| switch (err) {
...@@ -726,7 +726,7 @@ fn parseOs(result: *CrossTarget, diags: *ParseOptions.Diagnostics, text: []const...@@ -726,7 +726,7 @@ fn parseOs(result: *CrossTarget, diags: *ParseOptions.Diagnostics, text: []const
726 },726 },
727727
728 .windows => {728 .windows => {
729 var range_it = mem.split(u8, version_text, "...");729 var range_it = mem.splitFull(u8, version_text, "...");
730730
731 const min_text = range_it.first();731 const min_text = range_it.first();
732 const min_ver = std.meta.stringToEnum(Target.Os.WindowsVersion, min_text) orelse732 const min_ver = std.meta.stringToEnum(Target.Os.WindowsVersion, min_text) orelse
lib/std/zig/ErrorBundle.zig+1-1
...@@ -294,7 +294,7 @@ fn renderErrorMessageToWriter(...@@ -294,7 +294,7 @@ fn renderErrorMessageToWriter(
294///294///
295/// This is used to split the message in `@compileError("hello\nworld")` for example.295/// This is used to split the message in `@compileError("hello\nworld")` for example.
296fn writeMsg(eb: ErrorBundle, err_msg: ErrorMessage, stderr: anytype, indent: usize) !void {296fn writeMsg(eb: ErrorBundle, err_msg: ErrorMessage, stderr: anytype, indent: usize) !void {
297 var lines = std.mem.split(u8, eb.nullTerminatedString(err_msg.msg), "\n");297 var lines = std.mem.splitScalar(u8, eb.nullTerminatedString(err_msg.msg), '\n');
298 while (lines.next()) |line| {298 while (lines.next()) |line| {
299 try stderr.writeAll(line);299 try stderr.writeAll(line);
300 if (lines.index == null) break;300 if (lines.index == null) break;
lib/std/zig/render.zig+1-1
...@@ -1995,7 +1995,7 @@ fn renderArrayInit(...@@ -1995,7 +1995,7 @@ fn renderArrayInit(
1995 if (!expr_newlines[i]) {1995 if (!expr_newlines[i]) {
1996 try ais.writer().writeAll(expr_text);1996 try ais.writer().writeAll(expr_text);
1997 } else {1997 } else {
1998 var by_line = std.mem.split(u8, expr_text, "\n");1998 var by_line = std.mem.splitScalar(u8, expr_text, '\n');
1999 var last_line_was_empty = false;1999 var last_line_was_empty = false;
2000 try ais.writer().writeAll(by_line.first());2000 try ais.writer().writeAll(by_line.first());
2001 while (by_line.next()) |line| {2001 while (by_line.next()) |line| {
lib/std/zig/system/NativeTargetInfo.zig+1-1
...@@ -556,7 +556,7 @@ fn glibcVerFromSoFile(file: fs.File) !std.builtin.Version {...@@ -556,7 +556,7 @@ fn glibcVerFromSoFile(file: fs.File) !std.builtin.Version {
556 const dynstr_size = @intCast(usize, dynstr.size);556 const dynstr_size = @intCast(usize, dynstr.size);
557 const dynstr_bytes = buf[0..dynstr_size];557 const dynstr_bytes = buf[0..dynstr_size];
558 _ = try preadMin(file, dynstr_bytes, dynstr.offset, dynstr_bytes.len);558 _ = try preadMin(file, dynstr_bytes, dynstr.offset, dynstr_bytes.len);
559 var it = mem.split(u8, dynstr_bytes, &.{0});559 var it = mem.splitScalar(u8, dynstr_bytes, 0);
560 var max_ver: std.builtin.Version = .{ .major = 2, .minor = 2, .patch = 5 };560 var max_ver: std.builtin.Version = .{ .major = 2, .minor = 2, .patch = 5 };
561 while (it.next()) |s| {561 while (it.next()) |s| {
562 if (mem.startsWith(u8, s, "GLIBC_2.")) {562 if (mem.startsWith(u8, s, "GLIBC_2.")) {
src/Autodoc.zig+1-1
...@@ -4951,7 +4951,7 @@ fn findGuidePaths(self: *Autodoc, file: *File, str: []const u8) ![]const u8 {...@@ -4951,7 +4951,7 @@ fn findGuidePaths(self: *Autodoc, file: *File, str: []const u8) ![]const u8 {
49514951
4952 // TODO: this algo is kinda inefficient4952 // TODO: this algo is kinda inefficient
49534953
4954 var it = std.mem.split(u8, str, "\n");4954 var it = std.mem.splitScalar(u8, str, '\n');
4955 while (it.next()) |line| {4955 while (it.next()) |line| {
4956 const trimmed_line = std.mem.trim(u8, line, " ");4956 const trimmed_line = std.mem.trim(u8, line, " ");
4957 if (std.mem.startsWith(u8, trimmed_line, guide_prefix)) {4957 if (std.mem.startsWith(u8, trimmed_line, guide_prefix)) {
src/Compilation.zig+3-3
...@@ -4636,7 +4636,7 @@ pub fn hasSharedLibraryExt(filename: []const u8) bool {...@@ -4636,7 +4636,7 @@ pub fn hasSharedLibraryExt(filename: []const u8) bool {
4636 return true;4636 return true;
4637 }4637 }
4638 // Look for .so.X, .so.X.Y, .so.X.Y.Z4638 // Look for .so.X, .so.X.Y, .so.X.Y.Z
4639 var it = mem.split(u8, filename, ".");4639 var it = mem.splitScalar(u8, filename, '.');
4640 _ = it.first();4640 _ = it.first();
4641 var so_txt = it.next() orelse return false;4641 var so_txt = it.next() orelse return false;
4642 while (!mem.eql(u8, so_txt, "so")) {4642 while (!mem.eql(u8, so_txt, "so")) {
...@@ -5016,14 +5016,14 @@ fn parseLldStderr(comp: *Compilation, comptime prefix: []const u8, stderr: []con...@@ -5016,14 +5016,14 @@ fn parseLldStderr(comp: *Compilation, comptime prefix: []const u8, stderr: []con
5016 defer context_lines.deinit();5016 defer context_lines.deinit();
50175017
5018 var current_err: ?*LldError = null;5018 var current_err: ?*LldError = null;
5019 var lines = mem.split(u8, stderr, std.cstr.line_sep);5019 var lines = mem.splitFull(u8, stderr, std.cstr.line_sep);
5020 while (lines.next()) |line| {5020 while (lines.next()) |line| {
5021 if (mem.startsWith(u8, line, prefix ++ ":")) {5021 if (mem.startsWith(u8, line, prefix ++ ":")) {
5022 if (current_err) |err| {5022 if (current_err) |err| {
5023 err.context_lines = try context_lines.toOwnedSlice();5023 err.context_lines = try context_lines.toOwnedSlice();
5024 }5024 }
50255025
5026 var split = std.mem.split(u8, line, "error: ");5026 var split = std.mem.splitFull(u8, line, "error: ");
5027 _ = split.first();5027 _ = split.first();
50285028
5029 const duped_msg = try std.fmt.allocPrint(comp.gpa, "{s}: {s}", .{ prefix, split.rest() });5029 const duped_msg = try std.fmt.allocPrint(comp.gpa, "{s}: {s}", .{ prefix, split.rest() });
src/libc_installation.zig+1-1
...@@ -63,7 +63,7 @@ pub const LibCInstallation = struct {...@@ -63,7 +63,7 @@ pub const LibCInstallation = struct {
63 var it = std.mem.tokenizeScalar(u8, contents, '\n');63 var it = std.mem.tokenizeScalar(u8, contents, '\n');
64 while (it.next()) |line| {64 while (it.next()) |line| {
65 if (line.len == 0 or line[0] == '#') continue;65 if (line.len == 0 or line[0] == '#') continue;
66 var line_it = std.mem.split(u8, line, "=");66 var line_it = std.mem.splitScalar(u8, line, '=');
67 const name = line_it.first();67 const name = line_it.first();
68 const value = line_it.rest();68 const value = line_it.rest();
69 inline for (fields, 0..) |field, i| {69 inline for (fields, 0..) |field, i| {
src/link/MachO/Dylib.zig+1-1
...@@ -91,7 +91,7 @@ pub const Id = struct {...@@ -91,7 +91,7 @@ pub const Id = struct {
91 var out: u32 = 0;91 var out: u32 = 0;
92 var values: [3][]const u8 = undefined;92 var values: [3][]const u8 = undefined;
9393
94 var split = mem.split(u8, string, ".");94 var split = mem.splitScalar(u8, string, '.');
95 var count: u4 = 0;95 var count: u4 = 0;
96 while (split.next()) |value| {96 while (split.next()) |value| {
97 if (count > 2) {97 if (count > 2) {
src/main.zig+8-8
...@@ -976,7 +976,7 @@ fn buildOutputType(...@@ -976,7 +976,7 @@ fn buildOutputType(
976 }976 }
977 } else if (mem.eql(u8, arg, "--mod")) {977 } else if (mem.eql(u8, arg, "--mod")) {
978 const info = args_iter.nextOrFatal();978 const info = args_iter.nextOrFatal();
979 var info_it = mem.split(u8, info, ":");979 var info_it = mem.splitScalar(u8, info, ':');
980 const mod_name = info_it.next() orelse fatal("expected non-empty argument after {s}", .{arg});980 const mod_name = info_it.next() orelse fatal("expected non-empty argument after {s}", .{arg});
981 const deps_str = info_it.next() orelse fatal("expected 'name:deps:path' after {s}", .{arg});981 const deps_str = info_it.next() orelse fatal("expected 'name:deps:path' after {s}", .{arg});
982 const root_src_orig = info_it.rest();982 const root_src_orig = info_it.rest();
...@@ -1176,7 +1176,7 @@ fn buildOutputType(...@@ -1176,7 +1176,7 @@ fn buildOutputType(
1176 } else {1176 } else {
1177 if (build_options.omit_pkg_fetching_code) unreachable;1177 if (build_options.omit_pkg_fetching_code) unreachable;
1178 // example: --listen 127.0.0.1:90001178 // example: --listen 127.0.0.1:9000
1179 var it = std.mem.split(u8, next_arg, ":");1179 var it = std.mem.splitScalar(u8, next_arg, ':');
1180 const host = it.next().?;1180 const host = it.next().?;
1181 const port_text = it.next() orelse "14735";1181 const port_text = it.next() orelse "14735";
1182 const port = std.fmt.parseInt(u16, port_text, 10) catch |err|1182 const port = std.fmt.parseInt(u16, port_text, 10) catch |err|
...@@ -1673,7 +1673,7 @@ fn buildOutputType(...@@ -1673,7 +1673,7 @@ fn buildOutputType(
1673 },1673 },
1674 .rdynamic => rdynamic = true,1674 .rdynamic => rdynamic = true,
1675 .wl => {1675 .wl => {
1676 var split_it = mem.split(u8, it.only_arg, ",");1676 var split_it = mem.splitScalar(u8, it.only_arg, ',');
1677 while (split_it.next()) |linker_arg| {1677 while (split_it.next()) |linker_arg| {
1678 // Handle nested-joined args like `-Wl,-rpath=foo`.1678 // Handle nested-joined args like `-Wl,-rpath=foo`.
1679 // Must be prefixed with 1 or 2 dashes.1679 // Must be prefixed with 1 or 2 dashes.
...@@ -2183,17 +2183,17 @@ fn buildOutputType(...@@ -2183,17 +2183,17 @@ fn buildOutputType(
2183 const next_arg = linker_args_it.nextOrFatal();2183 const next_arg = linker_args_it.nextOrFatal();
2184 try symbol_wrap_set.put(arena, next_arg, {});2184 try symbol_wrap_set.put(arena, next_arg, {});
2185 } else if (mem.startsWith(u8, arg, "/subsystem:")) {2185 } else if (mem.startsWith(u8, arg, "/subsystem:")) {
2186 var split_it = mem.splitBackwards(u8, arg, ":");2186 var split_it = mem.splitBackwardsScalar(u8, arg, ':');
2187 subsystem = try parseSubSystem(split_it.first());2187 subsystem = try parseSubSystem(split_it.first());
2188 } else if (mem.startsWith(u8, arg, "/implib:")) {2188 } else if (mem.startsWith(u8, arg, "/implib:")) {
2189 var split_it = mem.splitBackwards(u8, arg, ":");2189 var split_it = mem.splitBackwardsScalar(u8, arg, ':');
2190 emit_implib = .{ .yes = split_it.first() };2190 emit_implib = .{ .yes = split_it.first() };
2191 emit_implib_arg_provided = true;2191 emit_implib_arg_provided = true;
2192 } else if (mem.startsWith(u8, arg, "/pdb:")) {2192 } else if (mem.startsWith(u8, arg, "/pdb:")) {
2193 var split_it = mem.splitBackwards(u8, arg, ":");2193 var split_it = mem.splitBackwardsScalar(u8, arg, ':');
2194 pdb_out_path = split_it.first();2194 pdb_out_path = split_it.first();
2195 } else if (mem.startsWith(u8, arg, "/version:")) {2195 } else if (mem.startsWith(u8, arg, "/version:")) {
2196 var split_it = mem.splitBackwards(u8, arg, ":");2196 var split_it = mem.splitBackwardsScalar(u8, arg, ':');
2197 const version_arg = split_it.first();2197 const version_arg = split_it.first();
2198 version = std.builtin.Version.parse(version_arg) catch |err| {2198 version = std.builtin.Version.parse(version_arg) catch |err| {
2199 fatal("unable to parse /version '{s}': {s}", .{ arg, @errorName(err) });2199 fatal("unable to parse /version '{s}': {s}", .{ arg, @errorName(err) });
...@@ -3534,7 +3534,7 @@ const ModuleDepIterator = struct {...@@ -3534,7 +3534,7 @@ const ModuleDepIterator = struct {
3534 split: mem.SplitIterator(u8, .scalar),3534 split: mem.SplitIterator(u8, .scalar),
35353535
3536 fn init(deps_str: []const u8) ModuleDepIterator {3536 fn init(deps_str: []const u8) ModuleDepIterator {
3537 return .{ .split = mem.split(u8, deps_str, ",") };3537 return .{ .split = mem.splitScalar(u8, deps_str, ',') };
3538 }3538 }
35393539
3540 const Dependency = struct {3540 const Dependency = struct {
test/src/Cases.zig+3-3
...@@ -877,7 +877,7 @@ const TestManifest = struct {...@@ -877,7 +877,7 @@ const TestManifest = struct {
877 if (trimmed.len == 0) break;877 if (trimmed.len == 0) break;
878878
879 // Parse key=value(s)879 // Parse key=value(s)
880 var kv_it = std.mem.split(u8, trimmed, "=");880 var kv_it = std.mem.splitScalar(u8, trimmed, '=');
881 const key = kv_it.first();881 const key = kv_it.first();
882 try manifest.config_map.putNoClobber(key, kv_it.next() orelse return error.MissingValuesForConfig);882 try manifest.config_map.putNoClobber(key, kv_it.next() orelse return error.MissingValuesForConfig);
883 }883 }
...@@ -895,7 +895,7 @@ const TestManifest = struct {...@@ -895,7 +895,7 @@ const TestManifest = struct {
895 ) ConfigValueIterator(T) {895 ) ConfigValueIterator(T) {
896 const bytes = self.config_map.get(key) orelse TestManifestConfigDefaults.get(self.type, key);896 const bytes = self.config_map.get(key) orelse TestManifestConfigDefaults.get(self.type, key);
897 return ConfigValueIterator(T){897 return ConfigValueIterator(T){
898 .inner = std.mem.split(u8, bytes, ","),898 .inner = std.mem.splitScalar(u8, bytes, ','),
899 };899 };
900 }900 }
901901
...@@ -1399,7 +1399,7 @@ fn runOneCase(...@@ -1399,7 +1399,7 @@ fn runOneCase(
1399 // Render the expected lines into a string that we can compare verbatim.1399 // Render the expected lines into a string that we can compare verbatim.
1400 var expected_generated = std.ArrayList(u8).init(arena);1400 var expected_generated = std.ArrayList(u8).init(arena);
14011401
1402 var actual_line_it = std.mem.split(u8, actual_stderr.items, "\n");1402 var actual_line_it = std.mem.splitScalar(u8, actual_stderr.items, '\n');
1403 for (expected_errors) |expect_line| {1403 for (expected_errors) |expect_line| {
1404 const actual_line = actual_line_it.next() orelse {1404 const actual_line = actual_line_it.next() orelse {
1405 try expected_generated.appendSlice(expect_line);1405 try expected_generated.appendSlice(expect_line);
test/src/check-stack-trace.zig+1-1
...@@ -27,7 +27,7 @@ pub fn main() !void {...@@ -27,7 +27,7 @@ pub fn main() !void {
27 var buf = std.ArrayList(u8).init(arena);27 var buf = std.ArrayList(u8).init(arena);
28 defer buf.deinit();28 defer buf.deinit();
29 if (stderr.len != 0 and stderr[stderr.len - 1] == '\n') stderr = stderr[0 .. stderr.len - 1];29 if (stderr.len != 0 and stderr[stderr.len - 1] == '\n') stderr = stderr[0 .. stderr.len - 1];
30 var it = mem.split(u8, stderr, "\n");30 var it = mem.splitScalar(u8, stderr, '\n');
31 process_lines: while (it.next()) |line| {31 process_lines: while (it.next()) |line| {
32 if (line.len == 0) continue;32 if (line.len == 0) continue;
3333
tools/gen_outline_atomics.zig+1-1
...@@ -88,7 +88,7 @@ fn writeFunction(...@@ -88,7 +88,7 @@ fn writeFunction(
88 \\ asm volatile (88 \\ asm volatile (
89 \\89 \\
90 );90 );
91 var iter = std.mem.split(u8, body, "\n");91 var iter = std.mem.splitScalar(u8, body, '\n');
92 while (iter.next()) |line| {92 while (iter.next()) |line| {
93 try w.writeAll(" \\\\");93 try w.writeAll(" \\\\");
94 try w.writeAll(line);94 try w.writeAll(line);
tools/update_crc_catalog.zig+1-1
...@@ -78,7 +78,7 @@ pub fn main() anyerror!void {...@@ -78,7 +78,7 @@ pub fn main() anyerror!void {
78 var residue: []const u8 = undefined;78 var residue: []const u8 = undefined;
79 var name: []const u8 = undefined;79 var name: []const u8 = undefined;
8080
81 var it = mem.split(u8, line, " ");81 var it = mem.splitFull(u8, line, " ");
82 while (it.next()) |property| {82 while (it.next()) |property| {
83 const i = mem.indexOf(u8, property, "=").?;83 const i = mem.indexOf(u8, property, "=").?;
84 const key = property[0..i];84 const key = property[0..i];
tools/update_spirv_features.zig+1-1
...@@ -19,7 +19,7 @@ const Version = struct {...@@ -19,7 +19,7 @@ const Version = struct {
19 minor: u32,19 minor: u32,
2020
21 fn parse(str: []const u8) !Version {21 fn parse(str: []const u8) !Version {
22 var it = std.mem.split(u8, str, ".");22 var it = std.mem.splitScalar(u8, str, '.');
2323
24 const major = it.first();24 const major = it.first();
25 const minor = it.next() orelse return error.InvalidVersion;25 const minor = it.next() orelse return error.InvalidVersion;