authorgravatar for der.teufel.mail@gmail.comKrzysztof Wolicki <der.teufel.mail@gmail.com> 2026-07-28 18:13:17+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-08-05 03:40:30+02:00
logab4028d5796c68ca3aeb649e475bceff394942fc
tree25161b7474a58fc08267b0a2d42ae60e4ccc82a3
parentf8c6193e4c4a2e404def6c641bbd958a0226c486

Update usages of most deprecated APIs

In particular renames of `std.mem.indexOf` family to `std.mem.find` and generic unmanaged containers

88 files changed, 253 insertions(+), 250 deletions(-)

lib/build-web/time_report.zig+3-3
...@@ -84,7 +84,7 @@ pub fn compileResultMessage(msg_bytes: []u8) error{ OutOfMemory, WriteFailed }!v...@@ -84,7 +84,7 @@ pub fn compileResultMessage(msg_bytes: []u8) error{ OutOfMemory, WriteFailed }!v
84 defer gpa.free(slowest_decls);84 defer gpa.free(slowest_decls);
8585
86 for (slowest_files) |*file_out| {86 for (slowest_files) |*file_out| {
87 const i = std.mem.indexOfScalar(u8, trailing, 0) orelse @panic("malformed CompileResult message");87 const i = std.mem.findScalar(u8, trailing, 0) orelse @panic("malformed CompileResult message");
88 file_out.* = .{88 file_out.* = .{
89 .name = trailing[0..i],89 .name = trailing[0..i],
90 .ns_sema = 0,90 .ns_sema = 0,
...@@ -95,7 +95,7 @@ pub fn compileResultMessage(msg_bytes: []u8) error{ OutOfMemory, WriteFailed }!v...@@ -95,7 +95,7 @@ pub fn compileResultMessage(msg_bytes: []u8) error{ OutOfMemory, WriteFailed }!v
95 }95 }
9696
97 for (slowest_decls) |*decl_out| {97 for (slowest_decls) |*decl_out| {
98 const i = std.mem.indexOfScalar(u8, trailing, 0) orelse @panic("malformed CompileResult message");98 const i = std.mem.findScalar(u8, trailing, 0) orelse @panic("malformed CompileResult message");
99 const file_idx = std.mem.readInt(u32, trailing[i..][1..5], .little);99 const file_idx = std.mem.readInt(u32, trailing[i..][1..5], .little);
100 const sema_count = std.mem.readInt(u32, trailing[i..][5..9], .little);100 const sema_count = std.mem.readInt(u32, trailing[i..][5..9], .little);
101 const sema_ns = std.mem.readInt(u64, trailing[i..][9..17], .little);101 const sema_ns = std.mem.readInt(u64, trailing[i..][9..17], .little);
...@@ -258,7 +258,7 @@ pub fn runTestResultMessage(msg_bytes: []u8) error{OutOfMemory}!void {...@@ -258,7 +258,7 @@ pub fn runTestResultMessage(msg_bytes: []u8) error{OutOfMemory}!void {
258 defer table_html.deinit(gpa);258 defer table_html.deinit(gpa);
259259
260 for (durations) |test_ns| {260 for (durations) |test_ns| {
261 const test_name_len = std.mem.indexOfScalar(u8, trailing[offset..], 0) orelse @panic("malformed RunTestResult message");261 const test_name_len = std.mem.findScalar(u8, trailing[offset..], 0) orelse @panic("malformed RunTestResult message");
262 const test_name = trailing[offset..][0..test_name_len];262 const test_name = trailing[offset..][0..test_name_len];
263 offset += test_name_len + 1;263 offset += test_name_len + 1;
264 try table_html.print(gpa, "<tr><th scope=\"row\"><code>{f}</code></th>", .{fmtEscapeHtml(test_name)});264 try table_html.print(gpa, "<tr><th scope=\"row\"><code>{f}</code></th>", .{fmtEscapeHtml(test_name)});
lib/compiler/Maker.zig+1-1
...@@ -3109,7 +3109,7 @@ pub fn printErrorMessages(...@@ -3109,7 +3109,7 @@ pub fn printErrorMessages(
3109 try stderr.setColor(.red);3109 try stderr.setColor(.red);
3110 try writer.writeAll("error:");3110 try writer.writeAll("error:");
3111 try stderr.setColor(.reset);3111 try stderr.setColor(.reset);
3112 if (std.mem.indexOfScalar(u8, msg, '\n') == null) {3112 if (std.mem.findScalar(u8, msg, '\n') == null) {
3113 try writer.print(" {s}\n", .{msg});3113 try writer.print(" {s}\n", .{msg});
3114 } else switch (multiline_errors) {3114 } else switch (multiline_errors) {
3115 .indent => {3115 .indent => {
lib/compiler/Maker/Fetch.zig+3-3
...@@ -1164,7 +1164,7 @@ const FileType = enum {...@@ -1164,7 +1164,7 @@ const FileType = enum {
1164 if (cd_header[value_start] != '=') return null;1164 if (cd_header[value_start] != '=') return null;
1165 value_start += 1;1165 value_start += 1;
11661166
1167 var value_end = std.mem.indexOfPos(u8, cd_header, value_start, ";") orelse cd_header.len;1167 var value_end = std.mem.findPos(u8, cd_header, value_start, ";") orelse cd_header.len;
1168 if (cd_header[value_end - 1] == '\"') {1168 if (cd_header[value_end - 1] == '\"') {
1169 value_end -= 1;1169 value_end -= 1;
1170 }1170 }
...@@ -1344,7 +1344,7 @@ fn unpackResource(...@@ -1344,7 +1344,7 @@ fn unpackResource(
1344 return f.fail(f.location_tok, try eb.addString("missing 'Content-Type' header"));1344 return f.fail(f.location_tok, try eb.addString("missing 'Content-Type' header"));
13451345
1346 // Extract the MIME type, ignoring charset and boundary directives1346 // Extract the MIME type, ignoring charset and boundary directives
1347 const mime_type_end = std.mem.indexOf(u8, content_type, ";") orelse content_type.len;1347 const mime_type_end = std.mem.find(u8, content_type, ";") orelse content_type.len;
1348 const mime_type = content_type[0..mime_type_end];1348 const mime_type = content_type[0..mime_type_end];
13491349
1350 if (ascii.eqlIgnoreCase(mime_type, "application/x-tar"))1350 if (ascii.eqlIgnoreCase(mime_type, "application/x-tar"))
...@@ -1455,7 +1455,7 @@ fn unpackTarball(f: *Fetch, out_dir: Io.Dir, reader: *Io.Reader) RunError!Unpack...@@ -1455,7 +1455,7 @@ fn unpackTarball(f: *Fetch, out_dir: Io.Dir, reader: *Io.Reader) RunError!Unpack
14551455
1456 var diagnostics: std.tar.Diagnostics = .{ .allocator = arena };1456 var diagnostics: std.tar.Diagnostics = .{ .allocator = arena };
14571457
1458 std.tar.pipeToFileSystem(io, out_dir, reader, .{1458 std.tar.extract(io, out_dir, reader, .{
1459 .diagnostics = &diagnostics,1459 .diagnostics = &diagnostics,
1460 .strip_components = 0,1460 .strip_components = 0,
1461 .mode_mode = .ignore,1461 .mode_mode = .ignore,
lib/compiler/Maker/Fetch/git.zig+6-6
...@@ -336,7 +336,7 @@ pub const Repository = struct {...@@ -336,7 +336,7 @@ pub const Repository = struct {
336 fn next(iterator: *TreeIterator) !?Entry {336 fn next(iterator: *TreeIterator) !?Entry {
337 if (iterator.pos == iterator.data.len) return null;337 if (iterator.pos == iterator.data.len) return null;
338338
339 const mode_end = mem.indexOfScalarPos(u8, iterator.data, iterator.pos, ' ') orelse return error.InvalidTree;339 const mode_end = mem.findScalarPos(u8, iterator.data, iterator.pos, ' ') orelse return error.InvalidTree;
340 const mode: packed struct {340 const mode: packed struct {
341 permission: u9,341 permission: u9,
342 unused: u3,342 unused: u3,
...@@ -351,7 +351,7 @@ pub const Repository = struct {...@@ -351,7 +351,7 @@ pub const Repository = struct {
351 };351 };
352 iterator.pos = mode_end + 1;352 iterator.pos = mode_end + 1;
353353
354 const name_end = mem.indexOfScalarPos(u8, iterator.data, iterator.pos, 0) orelse return error.InvalidTree;354 const name_end = mem.findScalarPos(u8, iterator.data, iterator.pos, 0) orelse return error.InvalidTree;
355 const name = iterator.data[iterator.pos..name_end :0];355 const name = iterator.data[iterator.pos..name_end :0];
356 iterator.pos = name_end + 1;356 iterator.pos = name_end + 1;
357357
...@@ -823,7 +823,7 @@ pub const Session = struct {...@@ -823,7 +823,7 @@ pub const Session = struct {
823 value: ?[]const u8 = null,823 value: ?[]const u8 = null,
824824
825 fn parse(data: []const u8) Capability {825 fn parse(data: []const u8) Capability {
826 return if (mem.indexOfScalar(u8, data, '=')) |separator_pos|826 return if (mem.findScalar(u8, data, '=')) |separator_pos|
827 .{ .key = data[0..separator_pos], .value = data[separator_pos + 1 ..] }827 .{ .key = data[0..separator_pos], .value = data[separator_pos + 1 ..] }
828 else828 else
829 .{ .key = data };829 .{ .key = data };
...@@ -941,17 +941,17 @@ pub const Session = struct {...@@ -941,17 +941,17 @@ pub const Session = struct {
941 .flush => return null,941 .flush => return null,
942 .data => |data| {942 .data => |data| {
943 const ref_data = Packet.normalizeText(data);943 const ref_data = Packet.normalizeText(data);
944 const oid_sep_pos = mem.indexOfScalar(u8, ref_data, ' ') orelse return error.InvalidRefPacket;944 const oid_sep_pos = mem.findScalar(u8, ref_data, ' ') orelse return error.InvalidRefPacket;
945 const oid = Oid.parse(it.format, data[0..oid_sep_pos]) catch return error.InvalidRefPacket;945 const oid = Oid.parse(it.format, data[0..oid_sep_pos]) catch return error.InvalidRefPacket;
946946
947 const name_sep_pos = mem.indexOfScalarPos(u8, ref_data, oid_sep_pos + 1, ' ') orelse ref_data.len;947 const name_sep_pos = mem.findScalarPos(u8, ref_data, oid_sep_pos + 1, ' ') orelse ref_data.len;
948 const name = ref_data[oid_sep_pos + 1 .. name_sep_pos];948 const name = ref_data[oid_sep_pos + 1 .. name_sep_pos];
949949
950 var symref_target: ?[]const u8 = null;950 var symref_target: ?[]const u8 = null;
951 var peeled: ?Oid = null;951 var peeled: ?Oid = null;
952 var last_sep_pos = name_sep_pos;952 var last_sep_pos = name_sep_pos;
953 while (last_sep_pos < ref_data.len) {953 while (last_sep_pos < ref_data.len) {
954 const next_sep_pos = mem.indexOfScalarPos(u8, ref_data, last_sep_pos + 1, ' ') orelse ref_data.len;954 const next_sep_pos = mem.findScalarPos(u8, ref_data, last_sep_pos + 1, ' ') orelse ref_data.len;
955 const attribute = ref_data[last_sep_pos + 1 .. next_sep_pos];955 const attribute = ref_data[last_sep_pos + 1 .. next_sep_pos];
956 if (mem.startsWith(u8, attribute, "symref-target:")) {956 if (mem.startsWith(u8, attribute, "symref-target:")) {
957 symref_target = attribute["symref-target:".len..];957 symref_target = attribute["symref-target:".len..];
lib/compiler/Maker/Step/Run.zig+2-2
...@@ -555,7 +555,7 @@ const FuzzTestRunner = struct {...@@ -555,7 +555,7 @@ const FuzzTestRunner = struct {
555555
556 const Instance = struct {556 const Instance = struct {
557 child: process.Child,557 child: process.Child,
558 message: std.ArrayListAligned(u8, .@"4"),558 message: std.array_list.Aligned(u8, .@"4"),
559 broadcast_written: usize,559 broadcast_written: usize,
560 stderr: std.ArrayList(u8),560 stderr: std.ArrayList(u8),
561 stdin_vec: [1][]u8,561 stdin_vec: [1][]u8,
...@@ -2120,7 +2120,7 @@ fn fmtSnapshotIndicatorLine(buf: []const u8, index: usize) std.fmt.Alt(...@@ -2120,7 +2120,7 @@ fn fmtSnapshotIndicatorLine(buf: []const u8, index: usize) std.fmt.Alt(
2120}2120}
21212121
2122fn snapshotIndicatorLine(line: FmtIndicatorLine, w: *std.Io.Writer) std.Io.Writer.Error!void {2122fn snapshotIndicatorLine(line: FmtIndicatorLine, w: *std.Io.Writer) std.Io.Writer.Error!void {
2123 const line_begin_index = if (std.mem.lastIndexOfScalar(u8, line.buf[0..line.index], '\n')) |line_begin|2123 const line_begin_index = if (std.mem.findScalarLast(u8, line.buf[0..line.index], '\n')) |line_begin|
2124 line_begin + 12124 line_begin + 1
2125 else2125 else
2126 0;2126 0;
lib/compiler/configurer.zig+1-1
...@@ -83,7 +83,7 @@ pub fn main(init: process.Init.Minimal) !void {...@@ -83,7 +83,7 @@ pub fn main(init: process.Init.Minimal) !void {
83 if (mem.cutPrefix(u8, arg, "-D")) |option_contents| {83 if (mem.cutPrefix(u8, arg, "-D")) |option_contents| {
84 if (option_contents.len == 0)84 if (option_contents.len == 0)
85 fatalWithHint("expected option name after '-D'", .{});85 fatalWithHint("expected option name after '-D'", .{});
86 if (mem.indexOfScalar(u8, option_contents, '=')) |name_end| {86 if (mem.findScalar(u8, option_contents, '=')) |name_end| {
87 const option_name = option_contents[0..name_end];87 const option_name = option_contents[0..name_end];
88 const option_value = option_contents[name_end + 1 ..];88 const option_value = option_contents[name_end + 1 ..];
89 if (try builder.addUserInputOption(option_name, option_value))89 if (try builder.addUserInputOption(option_name, option_value))
lib/compiler/resinator/compile.zig+3-3
...@@ -540,7 +540,7 @@ pub const Compiler = struct {...@@ -540,7 +540,7 @@ pub const Compiler = struct {
540 // This currently only checks for NUL bytes, but it should probably also check for540 // This currently only checks for NUL bytes, but it should probably also check for
541 // platform-specific invalid characters like '*', '?', '"', '<', '>', '|' (Windows)541 // platform-specific invalid characters like '*', '?', '"', '<', '>', '|' (Windows)
542 // Related: https://github.com/ziglang/zig/pull/14533#issuecomment-1416888193542 // Related: https://github.com/ziglang/zig/pull/14533#issuecomment-1416888193
543 if (std.mem.indexOfScalar(u8, filename_utf8, 0) != null) {543 if (std.mem.findScalar(u8, filename_utf8, 0) != null) {
544 return self.addErrorDetailsAndFail(.{544 return self.addErrorDetailsAndFail(.{
545 .err = .invalid_filename,545 .err = .invalid_filename,
546 .token = node.filename.getFirstToken(),546 .token = node.filename.getFirstToken(),
...@@ -2919,11 +2919,11 @@ fn validateSearchPath(path: []const u8) error{BadPathName}!void {...@@ -2919,11 +2919,11 @@ fn validateSearchPath(path: []const u8) error{BadPathName}!void {
2919 var component_iterator = std.fs.path.componentIterator(path);2919 var component_iterator = std.fs.path.componentIterator(path);
2920 while (component_iterator.next()) |component| {2920 while (component_iterator.next()) |component| {
2921 // https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file2921 // https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file
2922 if (std.mem.indexOfAny(u8, component.name, "\x00<>:\"|?*") != null) return error.BadPathName;2922 if (std.mem.findAny(u8, component.name, "\x00<>:\"|?*") != null) return error.BadPathName;
2923 }2923 }
2924 },2924 },
2925 else => {2925 else => {
2926 if (std.mem.indexOfScalar(u8, path, 0) != null) return error.BadPathName;2926 if (std.mem.findScalar(u8, path, 0) != null) return error.BadPathName;
2927 },2927 },
2928 }2928 }
2929}2929}
lib/compiler/resinator/cvtres.zig+1-1
...@@ -1056,7 +1056,7 @@ pub const supported_targets = struct {...@@ -1056,7 +1056,7 @@ pub const supported_targets = struct {
1056 comptime {1056 comptime {
1057 const info = @typeInfo(Arch).@"enum";1057 const info = @typeInfo(Arch).@"enum";
1058 for (info.field_names, info.field_values) |field_name, field_value| {1058 for (info.field_names, info.field_values) |field_name, field_value| {
1059 _ = std.mem.indexOfScalar(Arch, ordered_for_display, @fromBackingInt(@intCast(field_value))) orelse {1059 _ = std.mem.findScalar(Arch, ordered_for_display, @fromBackingInt(@intCast(field_value))) orelse {
1060 @compileError(std.fmt.comptimePrint("'{s}' missing from ordered_for_display", .{field_name}));1060 @compileError(std.fmt.comptimePrint("'{s}' missing from ordered_for_display", .{field_name}));
1061 };1061 };
1062 }1062 }
lib/compiler/resinator/errors.zig+1-1
...@@ -506,7 +506,7 @@ pub const ErrorDetails = struct {...@@ -506,7 +506,7 @@ pub const ErrorDetails = struct {
506 // We know that the token slice is a well-formed #pragma code_page(N), so506 // We know that the token slice is a well-formed #pragma code_page(N), so
507 // we can skip to the first ( and then get the number that follows507 // we can skip to the first ( and then get the number that follows
508 const token_slice = self.token.slice(source);508 const token_slice = self.token.slice(source);
509 var number_start = std.mem.indexOfScalar(u8, token_slice, '(').? + 1;509 var number_start = std.mem.findScalar(u8, token_slice, '(').? + 1;
510 while (std.ascii.isWhitespace(token_slice[number_start])) {510 while (std.ascii.isWhitespace(token_slice[number_start])) {
511 number_start += 1;511 number_start += 1;
512 }512 }
lib/compiler/resinator/source_mapping.zig+1-1
...@@ -538,7 +538,7 @@ pub fn handleLineCommand(allocator: Allocator, line_command: []const u8, current...@@ -538,7 +538,7 @@ pub fn handleLineCommand(allocator: Allocator, line_command: []const u8, current
538 defer allocator.free(filename);538 defer allocator.free(filename);
539539
540 // \x00 bytes in the filename is incompatible with how StringTable works540 // \x00 bytes in the filename is incompatible with how StringTable works
541 if (std.mem.indexOfScalar(u8, filename, '\x00') != null) return error.InvalidLineCommand;541 if (std.mem.findScalar(u8, filename, '\x00') != null) return error.InvalidLineCommand;
542542
543 current_mapping.line_num = linenum;543 current_mapping.line_num = linenum;
544 current_mapping.filename.clearRetainingCapacity();544 current_mapping.filename.clearRetainingCapacity();
lib/docs/wasm/html_render.zig+1-1
...@@ -62,7 +62,7 @@ pub fn fileSourceHtml(...@@ -62,7 +62,7 @@ pub fn fileSourceHtml(
62 var cursor: usize = ast.tokenStart(start_token);62 var cursor: usize = ast.tokenStart(start_token);
6363
64 var indent: usize = 0;64 var indent: usize = 0;
65 if (std.mem.lastIndexOf(u8, ast.source[0..cursor], "\n")) |newline_index| {65 if (std.mem.findLast(u8, ast.source[0..cursor], "\n")) |newline_index| {
66 for (ast.source[newline_index + 1 .. cursor]) |c| {66 for (ast.source[newline_index + 1 .. cursor]) |c| {
67 if (c == ' ') {67 if (c == ' ') {
68 indent += 1;68 indent += 1;
lib/docs/wasm/main.zig+3-3
...@@ -153,11 +153,11 @@ fn query_exec_fallible(query: []const u8, ignore_case: bool) !void {...@@ -153,11 +153,11 @@ fn query_exec_fallible(query: []const u8, ignore_case: bool) !void {
153 continue;153 continue;
154 }154 }
155 // substring, case insensitive match of full decl path155 // substring, case insensitive match of full decl path
156 if (std.mem.indexOf(u8, g.full_path_search_text_lower.items, term) != null) {156 if (std.mem.find(u8, g.full_path_search_text_lower.items, term) != null) {
157 points += 2;157 points += 2;
158 continue;158 continue;
159 }159 }
160 if (std.mem.indexOf(u8, g.doc_search_text.items, term) != null) {160 if (std.mem.find(u8, g.doc_search_text.items, term) != null) {
161 points += 1;161 points += 1;
162 continue;162 continue;
163 }163 }
...@@ -803,7 +803,7 @@ fn unpackInner(tar_bytes: []u8) !void {...@@ -803,7 +803,7 @@ fn unpackInner(tar_bytes: []u8) !void {
803 if (std.mem.endsWith(u8, tar_file.name, ".zig")) {803 if (std.mem.endsWith(u8, tar_file.name, ".zig")) {
804 log.debug("found file: '{s}'", .{tar_file.name});804 log.debug("found file: '{s}'", .{tar_file.name});
805 const file_name = try gpa.dupe(u8, tar_file.name);805 const file_name = try gpa.dupe(u8, tar_file.name);
806 if (std.mem.indexOfScalar(u8, file_name, '/')) |pkg_name_end| {806 if (std.mem.findScalar(u8, file_name, '/')) |pkg_name_end| {
807 const pkg_name = file_name[0..pkg_name_end];807 const pkg_name = file_name[0..pkg_name_end];
808 const gop = try Walk.modules.getOrPut(gpa, pkg_name);808 const gop = try Walk.modules.getOrPut(gpa, pkg_name);
809 const file: Walk.File.Index = @fromBackingInt(@intCast(Walk.files.entries.len));809 const file: Walk.File.Index = @fromBackingInt(@intCast(Walk.files.entries.len));
lib/docs/wasm/markdown/Parser.zig+10-10
...@@ -159,7 +159,7 @@ const Block = struct {...@@ -159,7 +159,7 @@ const Block = struct {
159 .heading => null,159 .heading => null,
160 .code_block => code_block: {160 .code_block => code_block: {
161 const trimmed = mem.trimEnd(u8, unindented, " \t");161 const trimmed = mem.trimEnd(u8, unindented, " \t");
162 if (mem.indexOfNone(u8, trimmed, "`") != null or trimmed.len != b.data.code_block.fence_len) {162 if (mem.findNone(u8, trimmed, "`") != null or trimmed.len != b.data.code_block.fence_len) {
163 const effective_indent = @min(indent, b.data.code_block.indent);163 const effective_indent = @min(indent, b.data.code_block.indent);
164 break :code_block line[effective_indent..];164 break :code_block line[effective_indent..];
165 } else {165 } else {
...@@ -594,7 +594,7 @@ fn startListItem(unindented_line: []const u8) ?ListItemStart {...@@ -594,7 +594,7 @@ fn startListItem(unindented_line: []const u8) ?ListItemStart {
594 };594 };
595 }595 }
596596
597 const number_end = mem.indexOfNone(u8, unindented_line, "0123456789") orelse return null;597 const number_end = mem.findNone(u8, unindented_line, "0123456789") orelse return null;
598 const after_number = unindented_line[number_end..];598 const after_number = unindented_line[number_end..];
599 const marker: Block.Data.ListMarker = if (mem.startsWith(u8, after_number, ". "))599 const marker: Block.Data.ListMarker = if (mem.startsWith(u8, after_number, ". "))
600 .number_dot600 .number_dot
...@@ -639,10 +639,10 @@ fn startTableRow(unindented_line: []const u8) ?TableRowStart {...@@ -639,10 +639,10 @@ fn startTableRow(unindented_line: []const u8) ?TableRowStart {
639 // Ignoring pipes in code spans allows table cells to contain639 // Ignoring pipes in code spans allows table cells to contain
640 // code using ||, for example.640 // code using ||, for example.
641 const open_start = i;641 const open_start = i;
642 i = mem.indexOfNonePos(u8, table_row_content, i, "`") orelse return null;642 i = mem.findNonePos(u8, table_row_content, i, "`") orelse return null;
643 const open_len = i - open_start;643 const open_len = i - open_start;
644 while (mem.indexOfScalarPos(u8, table_row_content, i, '`')) |close_start| {644 while (mem.findScalarPos(u8, table_row_content, i, '`')) |close_start| {
645 i = mem.indexOfNonePos(u8, table_row_content, close_start, "`") orelse return null;645 i = mem.findNonePos(u8, table_row_content, close_start, "`") orelse return null;
646 const close_len = i - close_start;646 const close_len = i - close_start;
647 if (close_len == open_len) break;647 if (close_len == open_len) break;
648 } else return null;648 } else return null;
...@@ -794,7 +794,7 @@ fn startCodeBlock(p: *Parser, unindented_line: []const u8) !?CodeBlockStart {...@@ -794,7 +794,7 @@ fn startCodeBlock(p: *Parser, unindented_line: []const u8) !?CodeBlockStart {
794 } else "";794 } else "";
795 // Code block tags may not contain backticks, since that would create795 // Code block tags may not contain backticks, since that would create
796 // potential confusion with inline code spans.796 // potential confusion with inline code spans.
797 if (fence_len < 3 or mem.indexOfScalar(u8, tag_bytes, '`') != null) return null;797 if (fence_len < 3 or mem.findScalar(u8, tag_bytes, '`') != null) return null;
798 return .{798 return .{
799 .tag = try p.addString(mem.trim(u8, tag_bytes, " ")),799 .tag = try p.addString(mem.trim(u8, tag_bytes, " ")),
800 .fence_len = fence_len,800 .fence_len = fence_len,
...@@ -1382,12 +1382,12 @@ const InlineParser = struct {...@@ -1382,12 +1382,12 @@ const InlineParser = struct {
1382 /// parsing.1382 /// parsing.
1383 fn parseCodeSpan(ip: *InlineParser) !void {1383 fn parseCodeSpan(ip: *InlineParser) !void {
1384 const opener_start = ip.pos;1384 const opener_start = ip.pos;
1385 ip.pos = mem.indexOfNonePos(u8, ip.content, ip.pos, "`") orelse ip.content.len;1385 ip.pos = mem.findNonePos(u8, ip.content, ip.pos, "`") orelse ip.content.len;
1386 const opener_len = ip.pos - opener_start;1386 const opener_len = ip.pos - opener_start;
13871387
1388 const start = ip.pos;1388 const start = ip.pos;
1389 const end = while (mem.indexOfScalarPos(u8, ip.content, ip.pos, '`')) |closer_start| {1389 const end = while (mem.findScalarPos(u8, ip.content, ip.pos, '`')) |closer_start| {
1390 ip.pos = mem.indexOfNonePos(u8, ip.content, closer_start, "`") orelse ip.content.len;1390 ip.pos = mem.findNonePos(u8, ip.content, closer_start, "`") orelse ip.content.len;
1391 const closer_len = ip.pos - closer_start;1391 const closer_len = ip.pos - closer_start;
13921392
1393 if (closer_len == opener_len) break closer_start;1393 if (closer_len == opener_len) break closer_start;
...@@ -1627,7 +1627,7 @@ fn addScratchStringLine(p: *Parser, line: []const u8) !void {...@@ -1627,7 +1627,7 @@ fn addScratchStringLine(p: *Parser, line: []const u8) !void {
1627}1627}
16281628
1629fn isBlank(line: []const u8) bool {1629fn isBlank(line: []const u8) bool {
1630 return mem.indexOfNone(u8, line, " \t") == null;1630 return mem.findNone(u8, line, " \t") == null;
1631}1631}
16321632
1633fn isPunctuation(c: u8) bool {1633fn isPunctuation(c: u8) bool {
lib/fuzzer.zig+1-1
...@@ -1085,7 +1085,7 @@ const Fuzzer = struct {...@@ -1085,7 +1085,7 @@ const Fuzzer = struct {
1085 fn removeBest(f: *Fuzzer, i: Input.Index, best_i: u32) void {1085 fn removeBest(f: *Fuzzer, i: Input.Index, best_i: u32) void {
1086 const t = &f.tests[f.test_i];1086 const t = &f.tests[f.test_i];
1087 const ref = &t.corpus.items(.ref)[@backingInt(i)];1087 const ref = &t.corpus.items(.ref)[@backingInt(i)];
1088 const list_i = mem.indexOfScalar(u32, ref.best_i_buf[0..ref.best_i_len], best_i).?;1088 const list_i = mem.findScalar(u32, ref.best_i_buf[0..ref.best_i_len], best_i).?;
1089 ref.best_i_len -= 1;1089 ref.best_i_len -= 1;
1090 ref.best_i_buf[list_i] = ref.best_i_buf[ref.best_i_len];1090 ref.best_i_buf[list_i] = ref.best_i_buf[ref.best_i_len];
10911091
lib/std/Build.zig+5-2
...@@ -830,7 +830,7 @@ pub fn addTest(b: *Build, options: TestOptions) *Step.Compile {...@@ -830,7 +830,7 @@ pub fn addTest(b: *Build, options: TestOptions) *Step.Compile {
830 .kind = if (options.emit_object) .test_obj else .@"test",830 .kind = if (options.emit_object) .test_obj else .@"test",
831 .root_module = options.root_module,831 .root_module = options.root_module,
832 .max_rss = options.max_rss,832 .max_rss = options.max_rss,
833 .filters = b.dupeStrings(options.filters),833 .filters = b.graph.dupeStrings(options.filters),
834 .test_runner = options.test_runner,834 .test_runner = options.test_runner,
835 .use_llvm = options.use_llvm,835 .use_llvm = options.use_llvm,
836 .use_lld = options.use_lld,836 .use_lld = options.use_lld,
...@@ -2648,7 +2648,10 @@ pub const LazyPath = union(enum) {...@@ -2648,7 +2648,10 @@ pub const LazyPath = union(enum) {
26482648
2649 fn dupeInner(lazy_path: LazyPath, arena: Allocator) LazyPath {2649 fn dupeInner(lazy_path: LazyPath, arena: Allocator) LazyPath {
2650 return switch (lazy_path) {2650 return switch (lazy_path) {
2651 .src_path => |sp| .{ .src_path = .{ .owner = sp.owner, .sub_path = sp.owner.dupePath(sp.sub_path) } },2651 .src_path => |sp| .{ .src_path = .{
2652 .owner = sp.owner,
2653 .sub_path = sp.owner.graph.dupePath(sp.sub_path),
2654 } },
2652 .cwd_relative => |p| .{ .cwd_relative = Graph.dupePathInner(arena, p) },2655 .cwd_relative => |p| .{ .cwd_relative = Graph.dupePathInner(arena, p) },
2653 .relative => |r| .{ .relative = r },2656 .relative => |r| .{ .relative = r },
2654 .generated => |gen| .{ .generated = .{2657 .generated => |gen| .{ .generated = .{
lib/std/Build/Configuration.zig+4-4
...@@ -121,7 +121,7 @@ pub const Wip = struct {...@@ -121,7 +121,7 @@ pub const Wip = struct {
121 }121 }
122122
123 pub fn hash(_: @This(), adapted_key: []const u8) u64 {123 pub fn hash(_: @This(), adapted_key: []const u8) u64 {
124 assert(std.mem.indexOfScalar(u8, adapted_key, 0) == null);124 assert(std.mem.findScalar(u8, adapted_key, 0) == null);
125 return std.hash_map.hashString(adapted_key);125 return std.hash_map.hashString(adapted_key);
126 }126 }
127 };127 };
...@@ -182,7 +182,7 @@ pub const Wip = struct {...@@ -182,7 +182,7 @@ pub const Wip = struct {
182182
183 pub fn addString(wip: *Wip, bytes: []const u8) Allocator.Error!String {183 pub fn addString(wip: *Wip, bytes: []const u8) Allocator.Error!String {
184 const gpa = wip.gpa;184 const gpa = wip.gpa;
185 assert(std.mem.indexOfScalar(u8, bytes, 0) == null);185 assert(std.mem.findScalar(u8, bytes, 0) == null);
186 const gop = try wip.string_table.getOrPutContextAdapted(186 const gop = try wip.string_table.getOrPutContextAdapted(
187 gpa,187 gpa,
188 @as([]const u8, bytes),188 @as([]const u8, bytes),
...@@ -439,7 +439,7 @@ pub const Wip = struct {...@@ -439,7 +439,7 @@ pub const Wip = struct {
439 /// Returned slice expires upon next append to the configuration.439 /// Returned slice expires upon next append to the configuration.
440 pub fn stringSlice(wip: *const Wip, s: String) [:0]const u8 {440 pub fn stringSlice(wip: *const Wip, s: String) [:0]const u8 {
441 const start_slice = wip.string_bytes.items[@backingInt(s)..];441 const start_slice = wip.string_bytes.items[@backingInt(s)..];
442 return start_slice[0..std.mem.indexOfScalar(u8, start_slice, 0).? :0];442 return start_slice[0..std.mem.findScalar(u8, start_slice, 0).? :0];
443 }443 }
444};444};
445445
...@@ -1953,7 +1953,7 @@ pub const String = enum(u32) {...@@ -1953,7 +1953,7 @@ pub const String = enum(u32) {
19531953
1954 pub fn slice(index: String, c: *const Configuration) [:0]const u8 {1954 pub fn slice(index: String, c: *const Configuration) [:0]const u8 {
1955 const start_slice = c.string_bytes[@backingInt(index)..];1955 const start_slice = c.string_bytes[@backingInt(index)..];
1956 return start_slice[0..std.mem.indexOfScalar(u8, start_slice, 0).? :0];1956 return start_slice[0..std.mem.findScalar(u8, start_slice, 0).? :0];
1957 }1957 }
1958};1958};
19591959
lib/std/Build/Module.zig+2-2
...@@ -402,8 +402,8 @@ pub fn addCSourceFiles(m: *Module, options: AddCSourceFilesOptions) void {...@@ -402,8 +402,8 @@ pub fn addCSourceFiles(m: *Module, options: AddCSourceFilesOptions) void {
402 const c_source_files = arena.create(CSourceFiles) catch @panic("OOM");402 const c_source_files = arena.create(CSourceFiles) catch @panic("OOM");
403 c_source_files.* = .{403 c_source_files.* = .{
404 .root = options.root orelse b.path(""),404 .root = options.root orelse b.path(""),
405 .files = b.dupeStrings(options.files),405 .files = b.graph.dupeStrings(options.files),
406 .flags = b.dupeStrings(options.flags),406 .flags = b.graph.dupeStrings(options.flags),
407 .language = options.language,407 .language = options.language,
408 };408 };
409 m.link_objects.append(arena, .{ .c_source_files = c_source_files }) catch @panic("OOM");409 m.link_objects.append(arena, .{ .c_source_files = c_source_files }) catch @panic("OOM");
lib/std/Build/Step/Compile.zig+1-1
...@@ -375,7 +375,7 @@ pub fn create(owner: *std.Build, options: Options) *Compile {...@@ -375,7 +375,7 @@ pub fn create(owner: *std.Build, options: Options) *Compile {
375 const graph = owner.graph;375 const graph = owner.graph;
376 const arena = graph.arena;376 const arena = graph.arena;
377377
378 const name = owner.dupe(options.name);378 const name = owner.graph.dupeString(options.name);
379 if (mem.find(u8, name, "/") != null or mem.find(u8, name, "\\") != null) {379 if (mem.find(u8, name, "/") != null or mem.find(u8, name, "\\") != null) {
380 panic("invalid name: '{s}'. It looks like a file path, but it is supposed to be the library or application name.", .{name});380 panic("invalid name: '{s}'. It looks like a file path, but it is supposed to be the library or application name.", .{name});
381 }381 }
lib/std/Io/Dispatch.zig+3-3
...@@ -2782,7 +2782,7 @@ fn realPath(ev: *Evented, fd: c.fd_t, out_buffer: []u8) File.RealPathError!usize...@@ -2782,7 +2782,7 @@ fn realPath(ev: *Evented, fd: c.fd_t, out_buffer: []u8) File.RealPathError!usize
2782 else => |err| return unexpectedErrno(err),2782 else => |err| return unexpectedErrno(err),
2783 }2783 }
2784 }2784 }
2785 const n = std.mem.indexOfScalar(u8, &buffer, 0) orelse buffer.len;2785 const n = std.mem.findScalar(u8, &buffer, 0) orelse buffer.len;
2786 if (n > out_buffer.len) return error.NameTooLong;2786 if (n > out_buffer.len) return error.NameTooLong;
2787 @memcpy(out_buffer[0..n], buffer[0..n]);2787 @memcpy(out_buffer[0..n], buffer[0..n]);
2788 return n;2788 return n;
...@@ -2804,7 +2804,7 @@ fn dirRealPathFile(...@@ -2804,7 +2804,7 @@ fn dirRealPathFile(
2804 while (true) {2804 while (true) {
2805 if (c.realpath(sub_path_posix, out_buffer.ptr)) |redundant_pointer| {2805 if (c.realpath(sub_path_posix, out_buffer.ptr)) |redundant_pointer| {
2806 assert(redundant_pointer == out_buffer.ptr);2806 assert(redundant_pointer == out_buffer.ptr);
2807 return std.mem.indexOfScalar(u8, out_buffer, 0) orelse out_buffer.len;2807 return std.mem.findScalar(u8, out_buffer, 0) orelse out_buffer.len;
2808 }2808 }
2809 const err: c.E = @fromBackingInt(@intCast(c._errno().*));2809 const err: c.E = @fromBackingInt(@intCast(c._errno().*));
2810 switch (err) {2810 switch (err) {
...@@ -3792,7 +3792,7 @@ fn fileRealPath(userdata: ?*anyopaque, file: File, out_buffer: []u8) File.RealPa...@@ -3792,7 +3792,7 @@ fn fileRealPath(userdata: ?*anyopaque, file: File, out_buffer: []u8) File.RealPa
3792 else => |err| return unexpectedErrno(err),3792 else => |err| return unexpectedErrno(err),
3793 }3793 }
3794 }3794 }
3795 const n = std.mem.indexOfScalar(u8, &buffer, 0) orelse buffer.len;3795 const n = std.mem.findScalar(u8, &buffer, 0) orelse buffer.len;
3796 if (n > out_buffer.len) return error.NameTooLong;3796 if (n > out_buffer.len) return error.NameTooLong;
3797 @memcpy(out_buffer[0..n], buffer[0..n]);3797 @memcpy(out_buffer[0..n], buffer[0..n]);
3798 return n;3798 return n;
lib/std/Io/Threaded.zig+5-5
...@@ -6836,7 +6836,7 @@ fn dirRealPathFilePosix(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, o...@@ -6836,7 +6836,7 @@ fn dirRealPathFilePosix(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, o
6836 if (std.c.realpath(sub_path_posix, out_buffer.ptr)) |redundant_pointer| {6836 if (std.c.realpath(sub_path_posix, out_buffer.ptr)) |redundant_pointer| {
6837 syscall.finish();6837 syscall.finish();
6838 assert(redundant_pointer == out_buffer.ptr);6838 assert(redundant_pointer == out_buffer.ptr);
6839 return std.mem.indexOfScalar(u8, out_buffer, 0) orelse out_buffer.len;6839 return std.mem.findScalar(u8, out_buffer, 0) orelse out_buffer.len;
6840 }6840 }
6841 const err: posix.E = @fromBackingInt(@intCast(std.c._errno().*));6841 const err: posix.E = @fromBackingInt(@intCast(std.c._errno().*));
6842 if (err == .INTR) {6842 if (err == .INTR) {
...@@ -6980,7 +6980,7 @@ fn realPathPosix(fd: posix.fd_t, out_buffer: []u8) File.RealPathError!usize {...@@ -6980,7 +6980,7 @@ fn realPathPosix(fd: posix.fd_t, out_buffer: []u8) File.RealPathError!usize {
6980 },6980 },
6981 }6981 }
6982 }6982 }
6983 const n = std.mem.indexOfScalar(u8, &sufficient_buffer, 0) orelse sufficient_buffer.len;6983 const n = std.mem.findScalar(u8, &sufficient_buffer, 0) orelse sufficient_buffer.len;
6984 if (n > out_buffer.len) return error.NameTooLong;6984 if (n > out_buffer.len) return error.NameTooLong;
6985 @memcpy(out_buffer[0..n], sufficient_buffer[0..n]);6985 @memcpy(out_buffer[0..n], sufficient_buffer[0..n]);
6986 return n;6986 return n;
...@@ -8999,7 +8999,7 @@ fn isCygwinPty(file: File) Io.Cancelable!bool {...@@ -8999,7 +8999,7 @@ fn isCygwinPty(file: File) Io.Cancelable!bool {
8999 // The name we get from NtQueryInformationFile will be prefixed with a '\', e.g. \msys-1888ae32e00d56aa-pty0-to-master8999 // The name we get from NtQueryInformationFile will be prefixed with a '\', e.g. \msys-1888ae32e00d56aa-pty0-to-master
9000 return (std.mem.startsWith(u16, name_wide, &[_]u16{ '\\', 'm', 's', 'y', 's', '-' }) or9000 return (std.mem.startsWith(u16, name_wide, &[_]u16{ '\\', 'm', 's', 'y', 's', '-' }) or
9001 std.mem.startsWith(u16, name_wide, &[_]u16{ '\\', 'c', 'y', 'g', 'w', 'i', 'n', '-' })) and9001 std.mem.startsWith(u16, name_wide, &[_]u16{ '\\', 'c', 'y', 'g', 'w', 'i', 'n', '-' })) and
9002 std.mem.indexOf(u16, name_wide, &[_]u16{ '-', 'p', 't', 'y' }) != null;9002 std.mem.find(u16, name_wide, &[_]u16{ '-', 'p', 't', 'y' }) != null;
9003}9003}
90049004
9005fn fileSetLength(userdata: ?*anyopaque, file: File, length: u64) File.SetLengthError!void {9005fn fileSetLength(userdata: ?*anyopaque, file: File, length: u64) File.SetLengthError!void {
...@@ -16315,7 +16315,7 @@ fn windowsCreateProcessPathExt(...@@ -16315,7 +16315,7 @@ fn windowsCreateProcessPathExt(
1631516315
16316 const is_bat_or_cmd = bat_or_cmd: {16316 const is_bat_or_cmd = bat_or_cmd: {
16317 const app_name = app_buf.items[0..app_name_len];16317 const app_name = app_buf.items[0..app_name_len];
16318 const ext_start = std.mem.lastIndexOfScalar(u16, app_name, '.') orelse break :bat_or_cmd false;16318 const ext_start = std.mem.findScalarLast(u16, app_name, '.') orelse break :bat_or_cmd false;
16319 const ext = app_name[ext_start..];16319 const ext = app_name[ext_start..];
16320 const ext_enum = windowsCreateProcessSupportsExtension(ext) orelse break :bat_or_cmd false;16320 const ext_enum = windowsCreateProcessSupportsExtension(ext) orelse break :bat_or_cmd false;
16321 switch (ext_enum) {16321 switch (ext_enum) {
...@@ -16351,7 +16351,7 @@ fn windowsCreateProcessPathExt(...@@ -16351,7 +16351,7 @@ fn windowsCreateProcessPathExt(
16351 // it's treated as an unrecoverable error. Otherwise, it'll be16351 // it's treated as an unrecoverable error. Otherwise, it'll be
16352 // skipped as normal.16352 // skipped as normal.
16353 const app_name = app_buf.items[0..app_name_len];16353 const app_name = app_buf.items[0..app_name_len];
16354 const ext_start = std.mem.lastIndexOfScalar(u16, app_name, '.') orelse break :unappended err;16354 const ext_start = std.mem.findScalarLast(u16, app_name, '.') orelse break :unappended err;
16355 const ext = app_name[ext_start..];16355 const ext = app_name[ext_start..];
16356 if (windows.eqlIgnoreCaseWtf16(ext, std.unicode.utf8ToUtf16LeStringLiteral(".EXE"))) {16356 if (windows.eqlIgnoreCaseWtf16(ext, std.unicode.utf8ToUtf16LeStringLiteral(".EXE"))) {
16357 return error.UnrecoverableInvalidExe;16357 return error.UnrecoverableInvalidExe;
lib/std/Uri.zig+4-4
...@@ -221,16 +221,16 @@ pub fn parseAfterScheme(scheme: []const u8, text: []const u8) ParseError!Uri {...@@ -221,16 +221,16 @@ pub fn parseAfterScheme(scheme: []const u8, text: []const u8) ParseError!Uri {
221 }221 }
222222
223 if (authority.len > start_of_host and authority[start_of_host] == '[') { // IPv6223 if (authority.len > start_of_host and authority[start_of_host] == '[') { // IPv6
224 end_of_host = std.mem.lastIndexOf(u8, authority, "]") orelse return error.InvalidFormat;224 end_of_host = std.mem.findLast(u8, authority, "]") orelse return error.InvalidFormat;
225 end_of_host += 1;225 end_of_host += 1;
226226
227 if (std.mem.lastIndexOf(u8, authority, ":")) |index| {227 if (std.mem.findLast(u8, authority, ":")) |index| {
228 if (index >= end_of_host) { // if not part of the V6 address field228 if (index >= end_of_host) { // if not part of the V6 address field
229 end_of_host = @min(end_of_host, index);229 end_of_host = @min(end_of_host, index);
230 uri.port = std.fmt.parseInt(u16, authority[index + 1 ..], 10) catch return error.InvalidPort;230 uri.port = std.fmt.parseInt(u16, authority[index + 1 ..], 10) catch return error.InvalidPort;
231 }231 }
232 }232 }
233 } else if (std.mem.lastIndexOf(u8, authority, ":")) |index| {233 } else if (std.mem.findLast(u8, authority, ":")) |index| {
234 if (index >= start_of_host) { // if not part of the userinfo field234 if (index >= start_of_host) { // if not part of the userinfo field
235 end_of_host = @min(end_of_host, index);235 end_of_host = @min(end_of_host, index);
236 uri.port = std.fmt.parseInt(u16, authority[index + 1 ..], 10) catch return error.InvalidPort;236 uri.port = std.fmt.parseInt(u16, authority[index + 1 ..], 10) catch return error.InvalidPort;
...@@ -475,7 +475,7 @@ fn merge_paths(base: Component, new: []u8, aux_buf: *[]u8) error{NoSpaceLeft}!Co...@@ -475,7 +475,7 @@ fn merge_paths(base: Component, new: []u8, aux_buf: *[]u8) error{NoSpaceLeft}!Co
475 var aux: Writer = .fixed(aux_buf.*);475 var aux: Writer = .fixed(aux_buf.*);
476 if (!base.isEmpty()) {476 if (!base.isEmpty()) {
477 base.formatPath(&aux) catch return error.NoSpaceLeft;477 base.formatPath(&aux) catch return error.NoSpaceLeft;
478 aux.end = std.mem.lastIndexOfScalar(u8, aux.buffered(), '/') orelse return remove_dot_segments(new);478 aux.end = std.mem.findScalarLast(u8, aux.buffered(), '/') orelse return remove_dot_segments(new);
479 }479 }
480 aux.print("/{s}", .{new}) catch return error.NoSpaceLeft;480 aux.print("/{s}", .{new}) catch return error.NoSpaceLeft;
481 const merged_path = remove_dot_segments(aux.buffered());481 const merged_path = remove_dot_segments(aux.buffered());
lib/std/array_hash_map.zig+7-7
...@@ -13,12 +13,12 @@ const hash_map = @This();...@@ -13,12 +13,12 @@ const hash_map = @This();
13///13///
14/// See `AutoContext` for a description of the hash and equal implementations.14/// See `AutoContext` for a description of the hash and equal implementations.
15pub fn Auto(comptime K: type, comptime V: type) type {15pub fn Auto(comptime K: type, comptime V: type) type {
16 return ArrayHashMap(K, V, AutoContext(K), !autoEqlIsCheap(K));16 return Custom(K, V, AutoContext(K), !autoEqlIsCheap(K));
17}17}
1818
19/// An `ArrayHashMap` with strings as keys.19/// An `ArrayHashMap` with strings as keys.
20pub fn String(comptime V: type) type {20pub fn String(comptime V: type) type {
21 return ArrayHashMap([]const u8, V, StringContext, true);21 return Custom([]const u8, V, StringContext, true);
22}22}
2323
24pub const StringContext = struct {24pub const StringContext = struct {
...@@ -2130,7 +2130,7 @@ test "0 sized key and 0 sized value" {...@@ -2130,7 +2130,7 @@ test "0 sized key and 0 sized value" {
2130test "setKey storehash true" {2130test "setKey storehash true" {
2131 const gpa = std.testing.allocator;2131 const gpa = std.testing.allocator;
21322132
2133 var map: ArrayHashMap(i32, i32, AutoContext(i32), true) = .empty;2133 var map: Custom(i32, i32, AutoContext(i32), true) = .empty;
2134 defer map.deinit(gpa);2134 defer map.deinit(gpa);
21352135
2136 try map.put(gpa, 12, 34);2136 try map.put(gpa, 12, 34);
...@@ -2146,7 +2146,7 @@ test "setKey storehash true" {...@@ -2146,7 +2146,7 @@ test "setKey storehash true" {
2146test "setKey storehash false" {2146test "setKey storehash false" {
2147 const gpa = std.testing.allocator;2147 const gpa = std.testing.allocator;
21482148
2149 var map: ArrayHashMap(i32, i32, AutoContext(i32), false) = .empty;2149 var map: Custom(i32, i32, AutoContext(i32), false) = .empty;
2150 defer map.deinit(gpa);2150 defer map.deinit(gpa);
21512151
2152 try map.put(gpa, 12, 34);2152 try map.put(gpa, 12, 34);
...@@ -2162,7 +2162,7 @@ test "setKey storehash false" {...@@ -2162,7 +2162,7 @@ test "setKey storehash false" {
2162test "setKey storehash false with index" {2162test "setKey storehash false with index" {
2163 const gpa = std.testing.allocator;2163 const gpa = std.testing.allocator;
21642164
2165 const T = ArrayHashMap(usize, usize, AutoContext(usize), false);2165 const T = Custom(usize, usize, AutoContext(usize), false);
21662166
2167 var map: T = .empty;2167 var map: T = .empty;
2168 defer map.deinit(gpa);2168 defer map.deinit(gpa);
...@@ -2180,9 +2180,9 @@ test "setKey storehash false with index" {...@@ -2180,9 +2180,9 @@ test "setKey storehash false with index" {
2180test "setKey storehash true with index" {2180test "setKey storehash true with index" {
2181 const gpa = std.testing.allocator;2181 const gpa = std.testing.allocator;
21822182
2183 const T = ArrayHashMap(usize, usize, AutoContext(usize), false);2183 const T = Custom(usize, usize, AutoContext(usize), false);
21842184
2185 var map: ArrayHashMap(usize, usize, AutoContext(usize), true) = .empty;2185 var map: Custom(usize, usize, AutoContext(usize), true) = .empty;
2186 defer map.deinit(gpa);2186 defer map.deinit(gpa);
21872187
2188 for (0..T.linear_scan_max + 1) |i| try map.put(gpa, i, i);2188 for (0..T.linear_scan_max + 1) |i| try map.put(gpa, i, i);
lib/std/crypto/Certificate.zig+3-3
...@@ -1148,9 +1148,9 @@ pub const rsa = struct {...@@ -1148,9 +1148,9 @@ pub const rsa = struct {
1148 }1148 }
1149 var m_p_buf: [8 + Hash.digest_length + Hash.digest_length]u8 = undefined;1149 var m_p_buf: [8 + Hash.digest_length + Hash.digest_length]u8 = undefined;
1150 var m_p = m_p_buf[0 .. 8 + Hash.digest_length + sLen];1150 var m_p = m_p_buf[0 .. 8 + Hash.digest_length + sLen];
1151 std.mem.copyForwards(u8, m_p, @as(*const [8]u8, &@splat(0)));1151 @memmove(m_p, @as(*const [8]u8, &@splat(0)));
1152 std.mem.copyForwards(u8, m_p[8..], &mHash);1152 @memmove(m_p[8..], &mHash);
1153 std.mem.copyForwards(u8, m_p[(8 + Hash.digest_length)..], salt);1153 @memmove(m_p[(8 + Hash.digest_length)..], salt);
11541154
1155 // 13. Let H' = Hash(M'), an octet string of length hLen.1155 // 13. Let H' = Hash(M'), an octet string of length hLen.
1156 var h_p: [Hash.digest_length]u8 = undefined;1156 var h_p: [Hash.digest_length]u8 = undefined;
lib/std/fs/path.zig+2-2
...@@ -1830,7 +1830,7 @@ fn testRelativeWindows(from: []const u8, to: []const u8, expected_output: []cons...@@ -1830,7 +1830,7 @@ fn testRelativeWindows(from: []const u8, to: []const u8, expected_output: []cons
1830/// pointer address range of `path`, even if it is length zero.1830/// pointer address range of `path`, even if it is length zero.
1831pub fn extension(path: []const u8) []const u8 {1831pub fn extension(path: []const u8) []const u8 {
1832 const filename = basename(path);1832 const filename = basename(path);
1833 const index = mem.lastIndexOfScalar(u8, filename, '.') orelse return path[path.len..];1833 const index = mem.findScalarLast(u8, filename, '.') orelse return path[path.len..];
1834 if (index == 0) return path[path.len..];1834 if (index == 0) return path[path.len..];
1835 return filename[index..];1835 return filename[index..];
1836}1836}
...@@ -1887,7 +1887,7 @@ test extension {...@@ -1887,7 +1887,7 @@ test extension {
1887/// - "hello/world/lib" ⇒ "lib"1887/// - "hello/world/lib" ⇒ "lib"
1888pub fn stem(path: []const u8) []const u8 {1888pub fn stem(path: []const u8) []const u8 {
1889 const filename = basename(path);1889 const filename = basename(path);
1890 const index = mem.lastIndexOfScalar(u8, filename, '.') orelse return filename[0..];1890 const index = mem.findScalarLast(u8, filename, '.') orelse return filename[0..];
1891 if (index == 0) return path;1891 if (index == 0) return path;
1892 return filename[0..index];1892 return filename[0..index];
1893}1893}
lib/std/heap/SafeAllocator.zig+1-1
...@@ -1519,7 +1519,7 @@ const FuzzSingleThreadedAllocator = struct {...@@ -1519,7 +1519,7 @@ const FuzzSingleThreadedAllocator = struct {
1519 @disableInstrumentation();1519 @disableInstrumentation();
15201520
1521 const allocs_slice = f.allocs.slice();1521 const allocs_slice = f.allocs.slice();
1522 const i = mem.indexOfScalar([*]u8, allocs_slice.items(.ptr), memory.ptr) orelse panic(1522 const i = mem.findScalar([*]u8, allocs_slice.items(.ptr), memory.ptr) orelse panic(
1523 "invalid SafeAllocator free of {f}",1523 "invalid SafeAllocator free of {f}",
1524 .{FormatMemory{ .memory = memory, .alignment = alignment }},1524 .{FormatMemory{ .memory = memory, .alignment = alignment }},
1525 );1525 );
lib/std/http/Server.zig+1-1
...@@ -102,7 +102,7 @@ pub const Request = struct {...@@ -102,7 +102,7 @@ pub const Request = struct {
102 const method = std.meta.stringToEnum(http.Method, first_line[0..method_end]) orelse102 const method = std.meta.stringToEnum(http.Method, first_line[0..method_end]) orelse
103 return error.UnknownHttpMethod;103 return error.UnknownHttpMethod;
104104
105 const version_start = mem.lastIndexOfScalar(u8, first_line, ' ') orelse105 const version_start = mem.findScalarLast(u8, first_line, ' ') orelse
106 return error.HttpHeadersInvalid;106 return error.HttpHeadersInvalid;
107 if (version_start == method_end) return error.HttpHeadersInvalid;107 if (version_start == method_end) return error.HttpHeadersInvalid;
108108
lib/std/mem.zig+16-16
...@@ -1528,7 +1528,7 @@ pub fn findLast(comptime T: type, haystack: []const T, needle: []const T) ?usize...@@ -1528,7 +1528,7 @@ pub fn findLast(comptime T: type, haystack: []const T, needle: []const T) ?usize
1528 if (needle.len == 0) return haystack.len;1528 if (needle.len == 0) return haystack.len;
15291529
1530 if (!std.meta.hasUniqueRepresentation(T) or haystack.len < 52 or needle.len <= 4)1530 if (!std.meta.hasUniqueRepresentation(T) or haystack.len < 52 or needle.len <= 4)
1531 return lastIndexOfLinear(T, haystack, needle);1531 return findLastLinear(T, haystack, needle);
15321532
1533 const haystack_bytes = sliceAsBytes(haystack);1533 const haystack_bytes = sliceAsBytes(haystack);
1534 const needle_bytes = sliceAsBytes(needle);1534 const needle_bytes = sliceAsBytes(needle);
...@@ -1583,26 +1583,26 @@ pub fn findPos(comptime T: type, haystack: []const T, start_index: usize, needle...@@ -1583,26 +1583,26 @@ pub fn findPos(comptime T: type, haystack: []const T, start_index: usize, needle
15831583
1584test find {1584test find {
1585 try testing.expect(find(u8, "one two three four five six seven eight nine ten eleven", "three four").? == 8);1585 try testing.expect(find(u8, "one two three four five six seven eight nine ten eleven", "three four").? == 8);
1586 try testing.expect(lastIndexOf(u8, "one two three four five six seven eight nine ten eleven", "three four").? == 8);1586 try testing.expect(findLast(u8, "one two three four five six seven eight nine ten eleven", "three four").? == 8);
1587 try testing.expect(find(u8, "one two three four five six seven eight nine ten eleven", "two two") == null);1587 try testing.expect(find(u8, "one two three four five six seven eight nine ten eleven", "two two") == null);
1588 try testing.expect(lastIndexOf(u8, "one two three four five six seven eight nine ten eleven", "two two") == null);1588 try testing.expect(findLast(u8, "one two three four five six seven eight nine ten eleven", "two two") == null);
15891589
1590 try testing.expect(find(u8, "one two three four five six seven eight nine ten", "").? == 0);1590 try testing.expect(find(u8, "one two three four five six seven eight nine ten", "").? == 0);
1591 try testing.expect(lastIndexOf(u8, "one two three four five six seven eight nine ten", "").? == 48);1591 try testing.expect(findLast(u8, "one two three four five six seven eight nine ten", "").? == 48);
15921592
1593 try testing.expect(find(u8, "one two three four", "four").? == 14);1593 try testing.expect(find(u8, "one two three four", "four").? == 14);
1594 try testing.expect(lastIndexOf(u8, "one two three two four", "two").? == 14);1594 try testing.expect(findLast(u8, "one two three two four", "two").? == 14);
1595 try testing.expect(find(u8, "one two three four", "gour") == null);1595 try testing.expect(find(u8, "one two three four", "gour") == null);
1596 try testing.expect(lastIndexOf(u8, "one two three four", "gour") == null);1596 try testing.expect(findLast(u8, "one two three four", "gour") == null);
1597 try testing.expect(find(u8, "foo", "foo").? == 0);1597 try testing.expect(find(u8, "foo", "foo").? == 0);
1598 try testing.expect(lastIndexOf(u8, "foo", "foo").? == 0);1598 try testing.expect(findLast(u8, "foo", "foo").? == 0);
1599 try testing.expect(find(u8, "foo", "fool") == null);1599 try testing.expect(find(u8, "foo", "fool") == null);
1600 try testing.expect(lastIndexOf(u8, "foo", "lfoo") == null);1600 try testing.expect(findLast(u8, "foo", "lfoo") == null);
1601 try testing.expect(lastIndexOf(u8, "foo", "fool") == null);1601 try testing.expect(findLast(u8, "foo", "fool") == null);
16021602
1603 try testing.expect(find(u8, "foo foo", "foo").? == 0);1603 try testing.expect(find(u8, "foo foo", "foo").? == 0);
1604 try testing.expect(lastIndexOf(u8, "foo foo", "foo").? == 4);1604 try testing.expect(findLast(u8, "foo foo", "foo").? == 4);
1605 try testing.expect(lastIndexOfAny(u8, "boo, cat", "abo").? == 6);1605 try testing.expect(findLastAny(u8, "boo, cat", "abo").? == 6);
1606 try testing.expect(findScalarLast(u8, "boo", 'o').? == 2);1606 try testing.expect(findScalarLast(u8, "boo", 'o').? == 2);
1607}1607}
16081608
...@@ -1624,13 +1624,13 @@ test "find multibyte" {...@@ -1624,13 +1624,13 @@ test "find multibyte" {
1624 // make haystack and needle long enough to trigger Boyer-Moore-Horspool algorithm1624 // make haystack and needle long enough to trigger Boyer-Moore-Horspool algorithm
1625 const haystack = [_]u16{ 0xbbaa, 0xccbb, 0xddcc, 0xeedd, 0xffee, 0x00ff } ++ @as([100]u16, @splat(0));1625 const haystack = [_]u16{ 0xbbaa, 0xccbb, 0xddcc, 0xeedd, 0xffee, 0x00ff } ++ @as([100]u16, @splat(0));
1626 const needle = [_]u16{ 0xbbaa, 0xccbb, 0xddcc, 0xeedd, 0xffee };1626 const needle = [_]u16{ 0xbbaa, 0xccbb, 0xddcc, 0xeedd, 0xffee };
1627 try testing.expectEqual(lastIndexOf(u16, &haystack, &needle), 0);1627 try testing.expectEqual(findLast(u16, &haystack, &needle), 0);
16281628
1629 // check for misaligned false positives (little and big endian)1629 // check for misaligned false positives (little and big endian)
1630 const needleLE = [_]u16{ 0xbbbb, 0xcccc, 0xdddd, 0xeeee, 0xffff };1630 const needleLE = [_]u16{ 0xbbbb, 0xcccc, 0xdddd, 0xeeee, 0xffff };
1631 try testing.expectEqual(lastIndexOf(u16, &haystack, &needleLE), null);1631 try testing.expectEqual(findLast(u16, &haystack, &needleLE), null);
1632 const needleBE = [_]u16{ 0xaacc, 0xbbdd, 0xccee, 0xddff, 0xee00 };1632 const needleBE = [_]u16{ 0xaacc, 0xbbdd, 0xccee, 0xddff, 0xee00 };
1633 try testing.expectEqual(lastIndexOf(u16, &haystack, &needleBE), null);1633 try testing.expectEqual(findLast(u16, &haystack, &needleBE), null);
1634 }1634 }
1635}1635}
16361636
...@@ -3485,8 +3485,8 @@ pub fn SplitBackwardsIterator(comptime T: type, comptime delimiter_type: Delimit...@@ -3485,8 +3485,8 @@ pub fn SplitBackwardsIterator(comptime T: type, comptime delimiter_type: Delimit
3485 pub fn next(self: *Self) ?[]const T {3485 pub fn next(self: *Self) ?[]const T {
3486 const end = self.index orelse return null;3486 const end = self.index orelse return null;
3487 const start = if (switch (delimiter_type) {3487 const start = if (switch (delimiter_type) {
3488 .sequence => lastIndexOf(T, self.buffer[0..end], self.delimiter),3488 .sequence => findLast(T, self.buffer[0..end], self.delimiter),
3489 .any => lastIndexOfAny(T, self.buffer[0..end], self.delimiter),3489 .any => findLastAny(T, self.buffer[0..end], self.delimiter),
3490 .scalar => findScalarLast(T, self.buffer[0..end], self.delimiter),3490 .scalar => findScalarLast(T, self.buffer[0..end], self.delimiter),
3491 }) |delim_start| blk: {3491 }) |delim_start| blk: {
3492 self.index = delim_start;3492 self.index = delim_start;
lib/std/os/linux/IoUring/test.zig+1-1
...@@ -2699,7 +2699,7 @@ inline fn skipKernelLessThan(required: std.SemanticVersion) !void {...@@ -2699,7 +2699,7 @@ inline fn skipKernelLessThan(required: std.SemanticVersion) !void {
26992699
2700 const release = mem.sliceTo(&uts.release, 0);2700 const release = mem.sliceTo(&uts.release, 0);
2701 // Strips potential extra, as kernel version might not be semver compliant, example "6.8.9-300.fc40.x86_64"2701 // Strips potential extra, as kernel version might not be semver compliant, example "6.8.9-300.fc40.x86_64"
2702 const extra_index = std.mem.indexOfAny(u8, release, "-+");2702 const extra_index = std.mem.findAny(u8, release, "-+");
2703 const stripped = release[0..(extra_index orelse release.len)];2703 const stripped = release[0..(extra_index orelse release.len)];
2704 // Make sure the input don't rely on the extra we just stripped2704 // Make sure the input don't rely on the extra we just stripped
2705 try testing.expect(required.pre == null and required.build == null);2705 try testing.expect(required.pre == null and required.build == null);
lib/std/tar/Writer.zig+1-1
...@@ -312,7 +312,7 @@ pub const Header = extern struct {...@@ -312,7 +312,7 @@ pub const Header = extern struct {
312312
313 // add as much to prefix as you can, must split at /313 // add as much to prefix as you can, must split at /
314 const prefix_remaining = max_prefix - prefix_pos;314 const prefix_remaining = max_prefix - prefix_pos;
315 if (std.mem.lastIndexOf(u8, sub_path[0..@min(prefix_remaining, sub_path.len)], &.{'/'})) |sep_pos| {315 if (std.mem.findLast(u8, sub_path[0..@min(prefix_remaining, sub_path.len)], &.{'/'})) |sep_pos| {
316 @memcpy(w.prefix[prefix_pos..][0..sep_pos], sub_path[0..sep_pos]);316 @memcpy(w.prefix[prefix_pos..][0..sep_pos], sub_path[0..sep_pos]);
317 if ((sub_path.len - sep_pos - 1) > max_name) return error.NameTooLong;317 if ((sub_path.len - sep_pos - 1) > max_name) return error.NameTooLong;
318 @memcpy(w.name[0..][0 .. sub_path.len - sep_pos - 1], sub_path[sep_pos + 1 ..]);318 @memcpy(w.name[0..][0 .. sub_path.len - sep_pos - 1], sub_path[sep_pos + 1 ..]);
lib/std/tar/test.zig+3-3
...@@ -474,14 +474,14 @@ test "should not overwrite existing file" {...@@ -474,14 +474,14 @@ test "should not overwrite existing file" {
474 defer root.cleanup();474 defer root.cleanup();
475 try testing.expectError(475 try testing.expectError(
476 error.PathAlreadyExists,476 error.PathAlreadyExists,
477 tar.pipeToFileSystem(io, root.dir, &r, .{ .mode_mode = .ignore, .strip_components = 1 }),477 tar.extract(io, root.dir, &r, .{ .mode_mode = .ignore, .strip_components = 1 }),
478 );478 );
479479
480 // Unpack with strip_components = 0 should pass480 // Unpack with strip_components = 0 should pass
481 r = .fixed(data);481 r = .fixed(data);
482 var root2 = std.testing.tmpDir(.{});482 var root2 = std.testing.tmpDir(.{});
483 defer root2.cleanup();483 defer root2.cleanup();
484 try tar.pipeToFileSystem(io, root2.dir, &r, .{ .mode_mode = .ignore, .strip_components = 0 });484 try tar.extract(io, root2.dir, &r, .{ .mode_mode = .ignore, .strip_components = 0 });
485}485}
486486
487test "case sensitivity" {487test "case sensitivity" {
...@@ -501,7 +501,7 @@ test "case sensitivity" {...@@ -501,7 +501,7 @@ test "case sensitivity" {
501 var root = std.testing.tmpDir(.{});501 var root = std.testing.tmpDir(.{});
502 defer root.cleanup();502 defer root.cleanup();
503503
504 tar.pipeToFileSystem(io, root.dir, &r, .{ .mode_mode = .ignore, .strip_components = 1 }) catch |err| {504 tar.extract(io, root.dir, &r, .{ .mode_mode = .ignore, .strip_components = 1 }) catch |err| {
505 // on case insensitive fs we fail on overwrite existing file505 // on case insensitive fs we fail on overwrite existing file
506 try testing.expectEqual(error.PathAlreadyExists, err);506 try testing.expectEqual(error.PathAlreadyExists, err);
507 return;507 return;
lib/std/testing.zig+1-1
...@@ -999,7 +999,7 @@ test "expectEqualDeep composite type" {...@@ -999,7 +999,7 @@ test "expectEqualDeep composite type" {
999}999}
10001000
1001fn printIndicatorLine(source: []const u8, indicator_index: usize) void {1001fn printIndicatorLine(source: []const u8, indicator_index: usize) void {
1002 const line_begin_index = if (std.mem.lastIndexOfScalar(u8, source[0..indicator_index], '\n')) |line_begin|1002 const line_begin_index = if (std.mem.findScalarLast(u8, source[0..indicator_index], '\n')) |line_begin|
1003 line_begin + 11003 line_begin + 1
1004 else1004 else
1005 0;1005 0;
lib/std/testing/Smith.zig+1-1
...@@ -52,7 +52,7 @@ pub inline fn baselineWeights(T: type) []const Weight {...@@ -52,7 +52,7 @@ pub inline fn baselineWeights(T: type) []const Weight {
52 .bool, .int, .float => i: {52 .bool, .int, .float => i: {
53 // Reject types that don't have a fixed bitsize (esp. usize)53 // Reject types that don't have a fixed bitsize (esp. usize)
54 // since they are not gauraunteed to fit in a u64 across targets.54 // since they are not gauraunteed to fit in a u64 across targets.
55 if (std.mem.indexOfScalar(type, &.{55 if (std.mem.findScalar(type, &.{
56 isize, usize,56 isize, usize,
57 c_char, c_longdouble,57 c_char, c_longdouble,
58 c_short, c_ushort,58 c_short, c_ushort,
lib/std/zig.zig+1-1
...@@ -1560,7 +1560,7 @@ pub fn resolvePath(...@@ -1560,7 +1560,7 @@ pub fn resolvePath(
1560 // Heuristic for a fast path: if no component is absolute and ".." never appears, we just need to resolve `paths`.1560 // Heuristic for a fast path: if no component is absolute and ".." never appears, we just need to resolve `paths`.
1561 for (paths) |p| {1561 for (paths) |p| {
1562 if (Dir.path.isAbsolute(p)) break; // absolute path1562 if (Dir.path.isAbsolute(p)) break; // absolute path
1563 if (mem.indexOf(u8, p, "..") != null) break; // may contain up-dir1563 if (mem.find(u8, p, "..") != null) break; // may contain up-dir
1564 } else {1564 } else {
1565 // no absolute path, no "..".1565 // no absolute path, no "..".
1566 const res = try Dir.path.resolve(gpa, paths);1566 const res = try Dir.path.resolve(gpa, paths);
lib/std/zig/Ast/Render.zig+5-5
...@@ -941,20 +941,20 @@ fn renderExpressionFixup(r: *Render, node: Ast.Node.Index, space: Space) Error!v...@@ -941,20 +941,20 @@ fn renderExpressionFixup(r: *Render, node: Ast.Node.Index, space: Space) Error!v
941}941}
942942
943fn drainNoNewline(w: *Writer, data: []const []const u8, splat: usize) Writer.Error!usize {943fn drainNoNewline(w: *Writer, data: []const []const u8, splat: usize) Writer.Error!usize {
944 if (std.mem.indexOfScalar(u8, w.buffered(), '\n') != null) {944 if (std.mem.findScalar(u8, w.buffered(), '\n') != null) {
945 return error.WriteFailed;945 return error.WriteFailed;
946 }946 }
947947
948 var n: usize = 0;948 var n: usize = 0;
949 for (data[0 .. data.len - 1]) |v| {949 for (data[0 .. data.len - 1]) |v| {
950 if (std.mem.indexOfScalar(u8, v, '\n') != null) {950 if (std.mem.findScalar(u8, v, '\n') != null) {
951 return error.WriteFailed;951 return error.WriteFailed;
952 }952 }
953 n += v.len;953 n += v.len;
954 }954 }
955955
956 const pattern = data[data.len - 1];956 const pattern = data[data.len - 1];
957 if (splat != 0 and std.mem.indexOfScalar(u8, pattern, '\n') != null) {957 if (splat != 0 and std.mem.findScalar(u8, pattern, '\n') != null) {
958 return error.WriteFailed;958 return error.WriteFailed;
959 }959 }
960 n += pattern.len * splat;960 n += pattern.len * splat;
...@@ -990,7 +990,7 @@ fn rendersMultiline(r: *const Render, node: Ast.Node.Index) error{OutOfMemory}!b...@@ -990,7 +990,7 @@ fn rendersMultiline(r: *const Render, node: Ast.Node.Index) error{OutOfMemory}!b
990 error.WriteFailed => return true,990 error.WriteFailed => return true,
991 };991 };
992 if (sub_ais.disabled_offset != null) return true;992 if (sub_ais.disabled_offset != null) return true;
993 if (std.mem.indexOfScalar(u8, no_nl_w.buffered(), '\n') != null) {993 if (std.mem.findScalar(u8, no_nl_w.buffered(), '\n') != null) {
994 return true;994 return true;
995 }995 }
996996
...@@ -2993,7 +2993,7 @@ fn hasMultilineString(tree: Ast, start_token: Ast.TokenIndex, end_token: Ast.Tok...@@ -2993,7 +2993,7 @@ fn hasMultilineString(tree: Ast, start_token: Ast.TokenIndex, end_token: Ast.Tok
2993/// Returns true if there exists a doc comment between the start2993/// Returns true if there exists a doc comment between the start
2994/// of token `start_token` and the start of token `end_token`.2994/// of token `start_token` and the start of token `end_token`.
2995fn hasDocComment(tree: Ast, start_token: Ast.TokenIndex, end_token: Ast.TokenIndex) bool {2995fn hasDocComment(tree: Ast, start_token: Ast.TokenIndex, end_token: Ast.TokenIndex) bool {
2996 return std.mem.indexOfScalar(2996 return std.mem.findScalar(
2997 Token.Tag,2997 Token.Tag,
2998 tree.tokens.items(.tag)[start_token..end_token],2998 tree.tokens.items(.tag)[start_token..end_token],
2999 .doc_comment,2999 .doc_comment,
lib/std/zig/llvm/Builder.zig+1-1
...@@ -9919,7 +9919,7 @@ pub fn attrs(self: *Builder, attributes: []Attribute.Index) Allocator.Error!Attr...@@ -9919,7 +9919,7 @@ pub fn attrs(self: *Builder, attributes: []Attribute.Index) Allocator.Error!Attr
9919pub fn fnAttrs(self: *Builder, fn_attributes: []const Attributes) Allocator.Error!FunctionAttributes {9919pub fn fnAttrs(self: *Builder, fn_attributes: []const Attributes) Allocator.Error!FunctionAttributes {
9920 try self.function_attributes_set.ensureUnusedCapacity(self.gpa, 1);9920 try self.function_attributes_set.ensureUnusedCapacity(self.gpa, 1);
9921 const function_attributes: FunctionAttributes = @fromBackingInt(try self.attrGeneric(@ptrCast(9921 const function_attributes: FunctionAttributes = @fromBackingInt(try self.attrGeneric(@ptrCast(
9922 fn_attributes[0..if (std.mem.lastIndexOfNone(Attributes, fn_attributes, &.{.none})) |last|9922 fn_attributes[0..if (std.mem.findLastNone(Attributes, fn_attributes, &.{.none})) |last|
9923 last + 19923 last + 1
9924 else9924 else
9925 0],9925 0],
lib/std/zip.zig+1-1
...@@ -109,7 +109,7 @@ pub const EndRecord = extern struct {...@@ -109,7 +109,7 @@ pub const EndRecord = extern struct {
109109
110 /// TODO audit this logic110 /// TODO audit this logic
111 pub fn findBuffer(buffer: []const u8) FindBufferError!EndRecord {111 pub fn findBuffer(buffer: []const u8) FindBufferError!EndRecord {
112 const pos = std.mem.lastIndexOf(u8, buffer, &end_record_sig) orelse return error.ZipNoEndRecord;112 const pos = std.mem.findLast(u8, buffer, &end_record_sig) orelse return error.ZipNoEndRecord;
113 if (pos + @sizeOf(EndRecord) > buffer.len) return error.EndOfStream;113 if (pos + @sizeOf(EndRecord) > buffer.len) return error.EndOfStream;
114 const record_ptr: *EndRecord = @ptrCast(buffer[pos..][0..@sizeOf(EndRecord)]);114 const record_ptr: *EndRecord = @ptrCast(buffer[pos..][0..@sizeOf(EndRecord)]);
115 var record = record_ptr.*;115 var record = record_ptr.*;
src/Air.zig+1-1
...@@ -1907,7 +1907,7 @@ pub const NullTerminatedString = enum(u32) {...@@ -1907,7 +1907,7 @@ pub const NullTerminatedString = enum(u32) {
1907 pub fn toSlice(nts: NullTerminatedString, air: Air) [:0]const u8 {1907 pub fn toSlice(nts: NullTerminatedString, air: Air) [:0]const u8 {
1908 if (nts == .none) return "";1908 if (nts == .none) return "";
1909 const bytes = std.mem.sliceAsBytes(air.extra.items[@backingInt(nts)..]);1909 const bytes = std.mem.sliceAsBytes(air.extra.items[@backingInt(nts)..]);
1910 return bytes[0..std.mem.indexOfScalar(u8, bytes, 0).? :0];1910 return bytes[0..std.mem.findScalar(u8, bytes, 0).? :0];
1911 }1911 }
1912};1912};
19131913
src/IncrementalDebugServer.zig+4-4
...@@ -130,7 +130,7 @@ fn serveStream(...@@ -130,7 +130,7 @@ fn serveStream(
130 try stream_writer.writeAll("zig> ");130 try stream_writer.writeAll("zig> ");
131 const untrimmed = try stream_reader.takeSentinel('\n');131 const untrimmed = try stream_reader.takeSentinel('\n');
132 const cmd_and_arg = std.mem.trim(u8, untrimmed, " \t\r\n");132 const cmd_and_arg = std.mem.trim(u8, untrimmed, " \t\r\n");
133 const cmd: []const u8, const arg: []const u8 = if (std.mem.indexOfScalar(u8, cmd_and_arg, ' ')) |i|133 const cmd: []const u8, const arg: []const u8 = if (std.mem.findScalar(u8, cmd_and_arg, ' ')) |i|
134 .{ cmd_and_arg[0..i], cmd_and_arg[i + 1 ..] }134 .{ cmd_and_arg[0..i], cmd_and_arg[i + 1 ..] }
135 else135 else
136 .{ cmd_and_arg, "" };136 .{ cmd_and_arg, "" };
...@@ -244,7 +244,7 @@ fn handleCommand(zcu: *Zcu, w: *Io.Writer, cmd_str: []const u8, arg_str: []const...@@ -244,7 +244,7 @@ fn handleCommand(zcu: *Zcu, w: *Io.Writer, cmd_str: []const u8, arg_str: []const
244 const ty: Type = .fromInterned(type_ip_index);244 const ty: Type = .fromInterned(type_ip_index);
245 const ty_name = ty.containerTypeName(ip).toSlice(ip);245 const ty_name = ty.containerTypeName(ip).toSlice(ip);
246 const success = switch (@as(u2, @intFromBool(anchor_start)) << 1 | @intFromBool(anchor_end)) {246 const success = switch (@as(u2, @intFromBool(anchor_start)) << 1 | @intFromBool(anchor_end)) {
247 0b00 => std.mem.indexOf(u8, ty_name, query) != null,247 0b00 => std.mem.find(u8, ty_name, query) != null,
248 0b01 => std.mem.endsWith(u8, ty_name, query),248 0b01 => std.mem.endsWith(u8, ty_name, query),
249 0b10 => std.mem.startsWith(u8, ty_name, query),249 0b10 => std.mem.startsWith(u8, ty_name, query),
250 0b11 => std.mem.eql(u8, ty_name, query),250 0b11 => std.mem.eql(u8, ty_name, query),
...@@ -265,7 +265,7 @@ fn handleCommand(zcu: *Zcu, w: *Io.Writer, cmd_str: []const u8, arg_str: []const...@@ -265,7 +265,7 @@ fn handleCommand(zcu: *Zcu, w: *Io.Writer, cmd_str: []const u8, arg_str: []const
265 const nav = ip.getNav(nav_index);265 const nav = ip.getNav(nav_index);
266 const nav_fqn = nav.fqn.toSlice(ip);266 const nav_fqn = nav.fqn.toSlice(ip);
267 const success = switch (@as(u2, @intFromBool(anchor_start)) << 1 | @intFromBool(anchor_end)) {267 const success = switch (@as(u2, @intFromBool(anchor_start)) << 1 | @intFromBool(anchor_end)) {
268 0b00 => std.mem.indexOf(u8, nav_fqn, query) != null,268 0b00 => std.mem.find(u8, nav_fqn, query) != null,
269 0b01 => std.mem.endsWith(u8, nav_fqn, query),269 0b01 => std.mem.endsWith(u8, nav_fqn, query),
270 0b10 => std.mem.startsWith(u8, nav_fqn, query),270 0b10 => std.mem.startsWith(u8, nav_fqn, query),
271 0b11 => std.mem.eql(u8, nav_fqn, query),271 0b11 => std.mem.eql(u8, nav_fqn, query),
...@@ -378,7 +378,7 @@ fn parseIndex(str: []const u8) ?u32 {...@@ -378,7 +378,7 @@ fn parseIndex(str: []const u8) ?u32 {
378 return std.fmt.parseInt(u32, str, 10) catch null;378 return std.fmt.parseInt(u32, str, 10) catch null;
379}379}
380fn parseAnalUnit(str: []const u8) ?AnalUnit {380fn parseAnalUnit(str: []const u8) ?AnalUnit {
381 const split_idx = std.mem.indexOfScalar(u8, str, ' ') orelse return null;381 const split_idx = std.mem.findScalar(u8, str, ' ') orelse return null;
382 const kind = str[0..split_idx];382 const kind = str[0..split_idx];
383 const idx_str = str[split_idx + 1 ..];383 const idx_str = str[split_idx + 1 ..];
384 if (std.mem.eql(u8, kind, "comptime")) {384 if (std.mem.eql(u8, kind, "comptime")) {
src/InternPool.zig+3-3
...@@ -1737,7 +1737,7 @@ pub const String = enum(u32) {...@@ -1737,7 +1737,7 @@ pub const String = enum(u32) {
1737 }1737 }
17381738
1739 pub fn toNullTerminatedString(string: String, len: u64, ip: *const InternPool) NullTerminatedString {1739 pub fn toNullTerminatedString(string: String, len: u64, ip: *const InternPool) NullTerminatedString {
1740 assert(std.mem.indexOfScalar(u8, string.toSlice(len, ip), 0) == null);1740 assert(std.mem.findScalar(u8, string.toSlice(len, ip), 0) == null);
1741 assert(string.at(len, ip) == 0);1741 assert(string.at(len, ip) == 0);
1742 return @fromBackingInt(@intCast(@backingInt(string)));1742 return @fromBackingInt(@intCast(@backingInt(string)));
1743 }1743 }
...@@ -1864,7 +1864,7 @@ pub const NullTerminatedString = enum(u32) {...@@ -1864,7 +1864,7 @@ pub const NullTerminatedString = enum(u32) {
1864 pub fn toUnsigned(string: NullTerminatedString, ip: *const InternPool) ?u32 {1864 pub fn toUnsigned(string: NullTerminatedString, ip: *const InternPool) ?u32 {
1865 const slice = string.toSlice(ip);1865 const slice = string.toSlice(ip);
1866 if (slice.len > 1 and slice[0] == '0') return null;1866 if (slice.len > 1 and slice[0] == '0') return null;
1867 if (std.mem.indexOfScalar(u8, slice, '_')) |_| return null;1867 if (std.mem.findScalar(u8, slice, '_')) |_| return null;
1868 return std.fmt.parseUnsigned(u32, slice, 10) catch null;1868 return std.fmt.parseUnsigned(u32, slice, 10) catch null;
1869 }1869 }
18701870
...@@ -11428,7 +11428,7 @@ pub fn getOrPutTrailingString(...@@ -11428,7 +11428,7 @@ pub fn getOrPutTrailingString(
11428 .tid = tid,11428 .tid = tid,
11429 .index = strings.mutate.len - 1,11429 .index = strings.mutate.len - 1,
11430 }).wrap(ip))));11430 }).wrap(ip))));
11431 const has_embedded_null = std.mem.indexOfScalar(u8, key, 0) != null;11431 const has_embedded_null = std.mem.findScalar(u8, key, 0) != null;
11432 switch (embedded_nulls) {11432 switch (embedded_nulls) {
11433 .no_embedded_nulls => assert(!has_embedded_null),11433 .no_embedded_nulls => assert(!has_embedded_null),
11434 .maybe_embedded_nulls => if (has_embedded_null) {11434 .maybe_embedded_nulls => if (has_embedded_null) {
src/Sema.zig+1-1
...@@ -34856,7 +34856,7 @@ pub fn resolveNavPtrModifiers(...@@ -34856,7 +34856,7 @@ pub fn resolveNavPtrModifiers(
34856 const linksection_body = zir_decl.linksection_body orelse break :ls .none;34856 const linksection_body = zir_decl.linksection_body orelse break :ls .none;
34857 const linksection_ref = try sema.resolveInlineBody(block, linksection_body, decl_inst);34857 const linksection_ref = try sema.resolveInlineBody(block, linksection_body, decl_inst);
34858 const bytes = try sema.toConstString(block, section_src, linksection_ref, .{ .simple = .@"linksection" });34858 const bytes = try sema.toConstString(block, section_src, linksection_ref, .{ .simple = .@"linksection" });
34859 if (std.mem.indexOfScalar(u8, bytes, 0) != null) {34859 if (std.mem.findScalar(u8, bytes, 0) != null) {
34860 return sema.fail(block, section_src, "linksection cannot contain null bytes", .{});34860 return sema.fail(block, section_src, "linksection cannot contain null bytes", .{});
34861 } else if (bytes.len == 0) {34861 } else if (bytes.len == 0) {
34862 return sema.fail(block, section_src, "linksection cannot be empty", .{});34862 return sema.fail(block, section_src, "linksection cannot be empty", .{});
src/Value.zig+1-1
...@@ -954,7 +954,7 @@ pub fn anyScalarIsZero(val: Value, zcu: *Zcu) bool {...@@ -954,7 +954,7 @@ pub fn anyScalarIsZero(val: Value, zcu: *Zcu) bool {
954 .bytes => |str| {954 .bytes => |str| {
955 const len = Type.fromInterned(agg.ty).vectorLen(zcu);955 const len = Type.fromInterned(agg.ty).vectorLen(zcu);
956 const slice = str.toSlice(len, &zcu.intern_pool);956 const slice = str.toSlice(len, &zcu.intern_pool);
957 return std.mem.indexOfScalar(u8, slice, 0) != null;957 return std.mem.findScalar(u8, slice, 0) != null;
958 },958 },
959 .elems => |elems| {959 .elems => |elems| {
960 for (elems) |elem| {960 for (elems) |elem| {
src/Zcu.zig+2-2
...@@ -652,7 +652,7 @@ pub const StdLangDecl = enum {...@@ -652,7 +652,7 @@ pub const StdLangDecl = enum {
652 return switch (decl) {652 return switch (decl) {
653 inline else => |tag| {653 inline else => |tag| {
654 const name = @tagName(tag);654 const name = @tagName(tag);
655 const split = (comptime std.mem.lastIndexOfScalar(u8, name, '.')) orelse return .{ .direct = name };655 const split = (comptime std.mem.findScalarLast(u8, name, '.')) orelse return .{ .direct = name };
656 const parent = @field(StdLangDecl, name[0..split]);656 const parent = @field(StdLangDecl, name[0..split]);
657 comptime assert(@backingInt(parent) < @backingInt(tag)); // dependencies ordered correctly657 comptime assert(@backingInt(parent) < @backingInt(tag)); // dependencies ordered correctly
658 return .{ .nested = .{ parent, name[split + 1 ..] } };658 return .{ .nested = .{ parent, name[split + 1 ..] } };
...@@ -4299,7 +4299,7 @@ fn resolveReferencesInner(zcu: *Zcu) Allocator.Error!std.array_hash_map.Auto(Ana...@@ -4299,7 +4299,7 @@ fn resolveReferencesInner(zcu: *Zcu) Allocator.Error!std.array_hash_map.Auto(Ana
4299 const fqn_slice = nav.fqn.toSlice(ip);4299 const fqn_slice = nav.fqn.toSlice(ip);
4300 if (comp.test_filters.len > 0) {4300 if (comp.test_filters.len > 0) {
4301 for (comp.test_filters) |test_filter| {4301 for (comp.test_filters) |test_filter| {
4302 if (std.mem.indexOf(u8, fqn_slice, test_filter) != null) break;4302 if (std.mem.find(u8, fqn_slice, test_filter) != null) break;
4303 } else break :a false;4303 } else break :a false;
4304 }4304 }
4305 break :a true;4305 break :a true;
src/Zcu/PerThread.zig+1-1
...@@ -3176,7 +3176,7 @@ const ScanDeclIter = struct {...@@ -3176,7 +3176,7 @@ const ScanDeclIter = struct {
3176 if (is_named and comp.test_filters.len > 0) {3176 if (is_named and comp.test_filters.len > 0) {
3177 const fqn_slice = fqn.toSlice(ip);3177 const fqn_slice = fqn.toSlice(ip);
3178 for (comp.test_filters) |test_filter| {3178 for (comp.test_filters) |test_filter| {
3179 if (std.mem.indexOf(u8, fqn_slice, test_filter) != null) break;3179 if (std.mem.find(u8, fqn_slice, test_filter) != null) break;
3180 } else break :a false;3180 } else break :a false;
3181 }3181 }
3182 try zcu.test_functions.put(gpa, nav, {});3182 try zcu.test_functions.put(gpa, nav, {});
src/codegen/aarch64/Assemble.zig+1-1
...@@ -163,7 +163,7 @@ const matchers = matchers: {...@@ -163,7 +163,7 @@ const matchers = matchers: {
163 arg.* = zonCast(param_type.?, instruction.encode[encode_index], symbols);163 arg.* = zonCast(param_type.?, instruction.encode[encode_index], symbols);
164 return @call(.auto, encode, args);164 return @call(.auto, encode, args);
165 } else if (pattern_token[0] == '<') {165 } else if (pattern_token[0] == '<') {
166 const symbol_name = comptime pattern_token[1 .. std.mem.indexOfScalarPos(u8, pattern_token, 1, '|') orelse166 const symbol_name = comptime pattern_token[1 .. std.mem.findScalarPos(u8, pattern_token, 1, '|') orelse
167 pattern_token.len - 1];167 pattern_token.len - 1];
168 const symbol = @field(Symbol, symbol_name);168 const symbol = @field(Symbol, symbol_name);
169 const symbol_ptr = &@field(symbols, symbol_name);169 const symbol_ptr = &@field(symbols, symbol_name);
src/codegen/aarch64/Select.zig+1-1
...@@ -2856,7 +2856,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory,...@@ -2856,7 +2856,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory,
2856 const remaining_source = std.mem.span(as.source);2856 const remaining_source = std.mem.span(as.source);
2857 return isel.fail("unable to assemble: '{s}'", .{std.mem.trim(2857 return isel.fail("unable to assemble: '{s}'", .{std.mem.trim(
2858 u8,2858 u8,
2859 as.source[0 .. std.mem.indexOfScalar(u8, remaining_source, '\n') orelse remaining_source.len],2859 as.source[0 .. std.mem.findScalar(u8, remaining_source, '\n') orelse remaining_source.len],
2860 &std.ascii.whitespace,2860 &std.ascii.whitespace,
2861 )});2861 )});
2862 },2862 },
src/codegen/c.zig+2-2
...@@ -5013,7 +5013,7 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {...@@ -5013,7 +5013,7 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {
5013 while (it.next()) |input| {5013 while (it.next()) |input| {
5014 const constraint = input.constraint;5014 const constraint = input.constraint;
50155015
5016 if (constraint.len < 1 or mem.indexOfScalar(u8, "=+&%", constraint[0]) != null or5016 if (constraint.len < 1 or mem.findScalar(u8, "=+&%", constraint[0]) != null or
5017 (constraint[0] == '{' and constraint[constraint.len - 1] != '}'))5017 (constraint[0] == '{' and constraint[constraint.len - 1] != '}'))
5018 {5018 {
5019 return f.fail("CBE: constraint not supported: '{s}'", .{constraint});5019 return f.fail("CBE: constraint not supported: '{s}'", .{constraint});
...@@ -5077,7 +5077,7 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {...@@ -5077,7 +5077,7 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {
5077 }5077 }
50785078
5079 const desc = mem.sliceTo(asm_source[src_i..], ']');5079 const desc = mem.sliceTo(asm_source[src_i..], ']');
5080 if (mem.indexOfScalar(u8, desc, ':')) |colon| {5080 if (mem.findScalar(u8, desc, ':')) |colon| {
5081 const name = desc[0..colon];5081 const name = desc[0..colon];
5082 const modifier = desc[colon + 1 ..];5082 const modifier = desc[colon + 1 ..];
50835083
src/codegen/riscv64/CodeGen.zig+3-3
...@@ -6235,8 +6235,8 @@ fn airAsm(func: *Func, inst: Air.Inst.Index) !void {...@@ -6235,8 +6235,8 @@ fn airAsm(func: *Func, inst: Air.Inst.Index) !void {
6235 next_op: for (&ops) |*op| {6235 next_op: for (&ops) |*op| {
6236 const op_str = while (!last_op) {6236 const op_str = while (!last_op) {
6237 const full_str = op_it.next() orelse break :next_op;6237 const full_str = op_it.next() orelse break :next_op;
6238 const code_str = if (mem.indexOfScalar(u8, full_str, '#') orelse6238 const code_str = if (mem.findScalar(u8, full_str, '#') orelse
6239 mem.indexOf(u8, full_str, "//")) |comment|6239 mem.find(u8, full_str, "//")) |comment|
6240 code: {6240 code: {
6241 last_op = true;6241 last_op = true;
6242 break :code full_str[0..comment];6242 break :code full_str[0..comment];
...@@ -6250,7 +6250,7 @@ fn airAsm(func: *Func, inst: Air.Inst.Index) !void {...@@ -6250,7 +6250,7 @@ fn airAsm(func: *Func, inst: Air.Inst.Index) !void {
6250 } else if (std.fmt.parseInt(i12, op_str, 10)) |int| {6250 } else if (std.fmt.parseInt(i12, op_str, 10)) |int| {
6251 op.* = .{ .imm = Immediate.s(int) };6251 op.* = .{ .imm = Immediate.s(int) };
6252 } else |_| if (mem.startsWith(u8, op_str, "%[")) {6252 } else |_| if (mem.startsWith(u8, op_str, "%[")) {
6253 const mod_index = mem.indexOf(u8, op_str, "]@");6253 const mod_index = mem.find(u8, op_str, "]@");
6254 const modifier = if (mod_index) |index|6254 const modifier = if (mod_index) |index|
6255 op_str[index + "]@".len ..]6255 op_str[index + "]@".len ..]
6256 else6256 else
src/codegen/x86_64/CodeGen.zig+15-15
...@@ -177899,7 +177899,7 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {...@@ -177899,7 +177899,7 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {
177899 else if (std.mem.endsWith(u8, mnem_str, "l"))177899 else if (std.mem.endsWith(u8, mnem_str, "l"))
177900 .dword177900 .dword
177901 else if (std.mem.endsWith(u8, mnem_str, "q") and177901 else if (std.mem.endsWith(u8, mnem_str, "q") and
177902 (std.mem.indexOfScalar(u8, "vp", mnem_str[0]) == null or177902 (std.mem.findScalar(u8, "vp", mnem_str[0]) == null or
177903 !std.mem.endsWith(u8, mnem_str, "dq")))177903 !std.mem.endsWith(u8, mnem_str, "dq")))
177904 .qword177904 .qword
177905 else if (std.mem.endsWith(u8, mnem_str, "t"))177905 else if (std.mem.endsWith(u8, mnem_str, "t"))
...@@ -177966,8 +177966,8 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {...@@ -177966,8 +177966,8 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {
177966 }) + 1,177966 }) + 1,
177967 }177967 }
177968 };177968 };
177969 const untrimmed_op_str = if (std.mem.indexOfScalar(u8, full_op_str, '#') orelse177969 const untrimmed_op_str = if (std.mem.findScalar(u8, full_op_str, '#') orelse
177970 std.mem.indexOf(u8, full_op_str, "//")) |comment|177970 std.mem.find(u8, full_op_str, "//")) |comment|
177971 untrimmed_op_str: {177971 untrimmed_op_str: {
177972 ops_index = ops_str.len;177972 ops_index = ops_str.len;
177973 break :untrimmed_op_str full_op_str[0..comment];177973 break :untrimmed_op_str full_op_str[0..comment];
...@@ -177976,7 +177976,7 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {...@@ -177976,7 +177976,7 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {
177976 if (trimmed_op_str.len > 0) break trimmed_op_str;177976 if (trimmed_op_str.len > 0) break trimmed_op_str;
177977 };177977 };
177978 if (std.mem.startsWith(u8, op_str, "%%")) {177978 if (std.mem.startsWith(u8, op_str, "%%")) {
177979 const colon = std.mem.indexOfScalarPos(u8, op_str, "%%".len + 2, ':');177979 const colon = std.mem.findScalarPos(u8, op_str, "%%".len + 2, ':');
177980 const reg = parseRegName(op_str["%%".len .. colon orelse op_str.len]) orelse177980 const reg = parseRegName(op_str["%%".len .. colon orelse op_str.len]) orelse
177981 return self.fail("invalid register: '{s}'", .{op_str});177981 return self.fail("invalid register: '{s}'", .{op_str});
177982 if (colon) |colon_pos| {177982 if (colon) |colon_pos| {
...@@ -177997,7 +177997,7 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {...@@ -177997,7 +177997,7 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {
177997 op.* = .{ .reg = reg };177997 op.* = .{ .reg = reg };
177998 }177998 }
177999 } else if (std.mem.startsWith(u8, op_str, "%[") and std.mem.endsWith(u8, op_str, "]")) {177999 } else if (std.mem.startsWith(u8, op_str, "%[") and std.mem.endsWith(u8, op_str, "]")) {
178000 const colon = std.mem.indexOfScalarPos(u8, op_str, "%[".len, ':');178000 const colon = std.mem.findScalarPos(u8, op_str, "%[".len, ':');
178001 const modifier = if (colon) |colon_pos|178001 const modifier = if (colon) |colon_pos|
178002 op_str[colon_pos + ":".len .. op_str.len - "]".len]178002 op_str[colon_pos + ":".len .. op_str.len - "]".len]
178003 else178003 else
...@@ -178080,7 +178080,7 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {...@@ -178080,7 +178080,7 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {
178080 else |_|178080 else |_|
178081 return self.fail("invalid immediate: '{s}'", .{op_str});178081 return self.fail("invalid immediate: '{s}'", .{op_str});
178082 } else if (std.mem.endsWith(u8, op_str, ")")) {178082 } else if (std.mem.endsWith(u8, op_str, ")")) {
178083 const open = std.mem.indexOfScalar(u8, op_str, '(') orelse178083 const open = std.mem.findScalar(u8, op_str, '(') orelse
178084 return self.fail("invalid operand: '{s}'", .{op_str});178084 return self.fail("invalid operand: '{s}'", .{op_str});
178085 var sib_it =178085 var sib_it =
178086 std.mem.splitScalar(u8, op_str[open + "(".len .. op_str.len - ")".len], ',');178086 std.mem.splitScalar(u8, op_str[open + "(".len .. op_str.len - ")".len], ',');
...@@ -178141,7 +178141,7 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {...@@ -178141,7 +178141,7 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {
178141 .disp = if (std.mem.startsWith(u8, op_str[0..open], "%[") and178141 .disp = if (std.mem.startsWith(u8, op_str[0..open], "%[") and
178142 std.mem.endsWith(u8, op_str[0..open], "]"))178142 std.mem.endsWith(u8, op_str[0..open], "]"))
178143 disp: {178143 disp: {
178144 const colon = std.mem.indexOfScalarPos(u8, op_str[0..open], "%[".len, ':');178144 const colon = std.mem.findScalarPos(u8, op_str[0..open], "%[".len, ':');
178145 const modifier = if (colon) |colon_pos|178145 const modifier = if (colon) |colon_pos|
178146 op_str[colon_pos + ":".len .. open - "]".len]178146 op_str[colon_pos + ":".len .. open - "]".len]
178147 else178147 else
...@@ -178210,14 +178210,14 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {...@@ -178210,14 +178210,14 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {
178210 .{ ._, .pseudo }178210 .{ ._, .pseudo }
178211 else for (std.enums.values(Mir.Inst.Fixes)) |fixes| {178211 else for (std.enums.values(Mir.Inst.Fixes)) |fixes| {
178212 const fixes_name = @tagName(fixes);178212 const fixes_name = @tagName(fixes);
178213 const space_index = std.mem.indexOfScalar(u8, fixes_name, ' ');178213 const space_index = std.mem.findScalar(u8, fixes_name, ' ');
178214 const fixes_prefix = if (space_index) |index|178214 const fixes_prefix = if (space_index) |index|
178215 std.meta.stringToEnum(encoder.Instruction.Prefix, fixes_name[0..index]).?178215 std.meta.stringToEnum(encoder.Instruction.Prefix, fixes_name[0..index]).?
178216 else178216 else
178217 .none;178217 .none;
178218 if (fixes_prefix != prefix) continue;178218 if (fixes_prefix != prefix) continue;
178219 const pattern = fixes_name[if (space_index) |index| index + " ".len else 0..];178219 const pattern = fixes_name[if (space_index) |index| index + " ".len else 0..];
178220 const wildcard_index = std.mem.indexOfScalar(u8, pattern, '_').?;178220 const wildcard_index = std.mem.findScalar(u8, pattern, '_').?;
178221 const mnem_prefix = pattern[0..wildcard_index];178221 const mnem_prefix = pattern[0..wildcard_index];
178222 const mnem_suffix = pattern[wildcard_index + "_".len ..];178222 const mnem_suffix = pattern[wildcard_index + "_".len ..];
178223 if (!std.mem.startsWith(u8, mnem_name, mnem_prefix)) continue;178223 if (!std.mem.startsWith(u8, mnem_name, mnem_prefix)) continue;
...@@ -178463,11 +178463,11 @@ fn moveStrategy(cg: *CodeGen, ty: Type, class: Register.Class, aligned: bool) !M...@@ -178463,11 +178463,11 @@ fn moveStrategy(cg: *CodeGen, ty: Type, class: Register.Class, aligned: bool) !M
178463 .sse => switch (ty.zigTypeTag(zcu)) {178463 .sse => switch (ty.zigTypeTag(zcu)) {
178464 else => {178464 else => {
178465 const classes = std.mem.sliceTo(&abi.classifySystemV(ty, zcu, cg.target, .other), .none);178465 const classes = std.mem.sliceTo(&abi.classifySystemV(ty, zcu, cg.target, .other), .none);
178466 assert(std.mem.indexOfNone(abi.Class, classes, &.{178466 assert(std.mem.findNone(abi.Class, classes, &.{
178467 .integer, .sse, .sseup, .memory, .float, .float_combine,178467 .integer, .sse, .sseup, .memory, .float, .float_combine,
178468 }) == null);178468 }) == null);
178469 const abi_size = ty.abiSize(zcu);178469 const abi_size = ty.abiSize(zcu);
178470 if (abi_size < 4 or std.mem.indexOfScalar(abi.Class, classes, .integer) != null) switch (abi_size) {178470 if (abi_size < 4 or std.mem.findScalar(abi.Class, classes, .integer) != null) switch (abi_size) {
178471 1 => return if (cg.hasFeature(.avx)) .{ .vex_insert_extract = .{178471 1 => return if (cg.hasFeature(.avx)) .{ .vex_insert_extract = .{
178472 .insert = .{ .vp_b, .insr },178472 .insert = .{ .vp_b, .insr },
178473 .extract = .{ .vp_b, .extr },178473 .extract = .{ .vp_b, .extr },
...@@ -183578,8 +183578,8 @@ const Temp = struct {...@@ -183578,8 +183578,8 @@ const Temp = struct {
183578 const class = classes[class_index];183578 const class = classes[class_index];
183579 next_class_index = @intCast(switch (class) {183579 next_class_index = @intCast(switch (class) {
183580 .integer, .memory, .float, .float_combine => class_index + 1,183580 .integer, .memory, .float, .float_combine => class_index + 1,
183581 .sse => std.mem.indexOfNonePos(abi.Class, classes, class_index + 1, &.{.sseup}) orelse classes.len,183581 .sse => std.mem.findNonePos(abi.Class, classes, class_index + 1, &.{.sseup}) orelse classes.len,
183582 .x87 => std.mem.indexOfNonePos(abi.Class, classes, class_index + 1, &.{.x87up}) orelse classes.len,183582 .x87 => std.mem.findNonePos(abi.Class, classes, class_index + 1, &.{.x87up}) orelse classes.len,
183583 .sseup,183583 .sseup,
183584 .x87up,183584 .x87up,
183585 .none,183585 .none,
...@@ -189825,7 +189825,7 @@ const Select = struct {...@@ -189825,7 +189825,7 @@ const Select = struct {
189825 s.cg.asmOps(mir_tag, mir_ops) catch |err| switch (err) {189825 s.cg.asmOps(mir_tag, mir_ops) catch |err| switch (err) {
189826 error.InvalidInstruction => {189826 error.InvalidInstruction => {
189827 const fixes = @tagName(mir_tag[0]);189827 const fixes = @tagName(mir_tag[0]);
189828 const fixes_blank = std.mem.indexOfScalar(u8, fixes, '_').?;189828 const fixes_blank = std.mem.findScalar(u8, fixes, '_').?;
189829 return s.cg.fail("invalid instruction: '{s}{s}{s} {s} {s} {s} {s}'", .{189829 return s.cg.fail("invalid instruction: '{s}{s}{s} {s} {s} {s} {s}'", .{
189830 fixes[0..fixes_blank],189830 fixes[0..fixes_blank],
189831 @tagName(mir_tag[1]),189831 @tagName(mir_tag[1]),
...@@ -189905,7 +189905,7 @@ const Select = struct {...@@ -189905,7 +189905,7 @@ const Select = struct {
189905 .add, .com, .comi, .div, .divr, .mul, .st, .sub, .subr, .ucom, .ucomi => s.top +%= 1,189905 .add, .com, .comi, .div, .divr, .mul, .st, .sub, .subr, .ucom, .ucomi => s.top +%= 1,
189906 else => {189906 else => {
189907 const fixes = @tagName(mir_tag[0]);189907 const fixes = @tagName(mir_tag[0]);
189908 const fixes_blank = std.mem.indexOfScalar(u8, fixes, '_').?;189908 const fixes_blank = std.mem.findScalar(u8, fixes, '_').?;
189909 std.debug.panic("{s}: {s}{s}{s}\n", .{189909 std.debug.panic("{s}: {s}{s}{s}\n", .{
189910 @src().fn_name,189910 @src().fn_name,
189911 fixes[0..fixes_blank],189911 fixes[0..fixes_blank],
src/codegen/x86_64/Lower.zig+5-5
...@@ -435,11 +435,11 @@ const mnemonic_table: [inst_tags_len * inst_fixes_len]?Mnemonic = table: {...@@ -435,11 +435,11 @@ const mnemonic_table: [inst_tags_len * inst_fixes_len]?Mnemonic = table: {
435 for (0..inst_fixes_len) |fixes_i| {435 for (0..inst_fixes_len) |fixes_i| {
436 const fixes: Mir.Inst.Fixes = @fromBackingInt(@intCast(fixes_i));436 const fixes: Mir.Inst.Fixes = @fromBackingInt(@intCast(fixes_i));
437 const prefix, const suffix = affix: {437 const prefix, const suffix = affix: {
438 const pattern = if (std.mem.indexOfScalar(u8, @tagName(fixes), ' ')) |i|438 const pattern = if (std.mem.findScalar(u8, @tagName(fixes), ' ')) |i|
439 @tagName(fixes)[i + 1 ..]439 @tagName(fixes)[i + 1 ..]
440 else440 else
441 @tagName(fixes);441 @tagName(fixes);
442 const wildcard_idx = std.mem.indexOfScalar(u8, pattern, '_').?;442 const wildcard_idx = std.mem.findScalar(u8, pattern, '_').?;
443 break :affix .{ pattern[0..wildcard_idx], pattern[wildcard_idx + 1 ..] };443 break :affix .{ pattern[0..wildcard_idx], pattern[wildcard_idx + 1 ..] };
444 };444 };
445 for (0..inst_tags_len) |inst_tag_i| {445 for (0..inst_tags_len) |inst_tag_i| {
...@@ -477,7 +477,7 @@ fn generic(lower: *Lower, inst: Mir.Inst) Error!void {...@@ -477,7 +477,7 @@ fn generic(lower: *Lower, inst: Mir.Inst) Error!void {
477 else => return lower.fail("TODO lower .{s}", .{@tagName(inst.ops)}),477 else => return lower.fail("TODO lower .{s}", .{@tagName(inst.ops)}),
478 };478 };
479 try lower.encode(switch (fixes) {479 try lower.encode(switch (fixes) {
480 inline else => |tag| comptime if (std.mem.indexOfScalar(u8, @tagName(tag), ' ')) |space|480 inline else => |tag| comptime if (std.mem.findScalar(u8, @tagName(tag), ' ')) |space|
481 @field(Prefix, @tagName(tag)[0..space])481 @field(Prefix, @tagName(tag)[0..space])
482 else482 else
483 .none,483 .none,
...@@ -487,8 +487,8 @@ fn generic(lower: *Lower, inst: Mir.Inst) Error!void {...@@ -487,8 +487,8 @@ fn generic(lower: *Lower, inst: Mir.Inst) Error!void {
487 }487 }
488 // This combination is invalid; make the theoretical mnemonic name and emit an error with it.488 // This combination is invalid; make the theoretical mnemonic name and emit an error with it.
489 const fixes_name = @tagName(fixes);489 const fixes_name = @tagName(fixes);
490 const pattern = fixes_name[if (std.mem.indexOfScalar(u8, fixes_name, ' ')) |i| i + " ".len else 0..];490 const pattern = fixes_name[if (std.mem.findScalar(u8, fixes_name, ' ')) |i| i + " ".len else 0..];
491 const wildcard_index = std.mem.indexOfScalar(u8, pattern, '_').?;491 const wildcard_index = std.mem.findScalar(u8, pattern, '_').?;
492 return lower.fail("unsupported mnemonic: '{s}{s}{s}'", .{492 return lower.fail("unsupported mnemonic: '{s}{s}{s}'", .{
493 pattern[0..wildcard_index],493 pattern[0..wildcard_index],
494 @tagName(inst.tag),494 @tagName(inst.tag),
src/codegen/x86_64/Mir.zig+3-3
...@@ -1745,8 +1745,8 @@ pub const Inst = struct {...@@ -1745,8 +1745,8 @@ pub const Inst = struct {
1745 for (@typeInfo(Mnemonic).@"enum".field_names) |mnemonic_name| {1745 for (@typeInfo(Mnemonic).@"enum".field_names) |mnemonic_name| {
1746 if (mnemonic_name[0] == '.') continue;1746 if (mnemonic_name[0] == '.') continue;
1747 for (@typeInfo(Fixes).@"enum".field_names) |fixes_name| {1747 for (@typeInfo(Fixes).@"enum".field_names) |fixes_name| {
1748 const pattern = fixes_name[if (std.mem.indexOfScalar(u8, fixes_name, ' ')) |index| index + " ".len else 0..];1748 const pattern = fixes_name[if (std.mem.findScalar(u8, fixes_name, ' ')) |index| index + " ".len else 0..];
1749 const wildcard_index = std.mem.indexOfScalar(u8, pattern, '_').?;1749 const wildcard_index = std.mem.findScalar(u8, pattern, '_').?;
1750 const mnem_prefix = pattern[0..wildcard_index];1750 const mnem_prefix = pattern[0..wildcard_index];
1751 const mnem_suffix = pattern[wildcard_index + "_".len ..];1751 const mnem_suffix = pattern[wildcard_index + "_".len ..];
1752 if (!std.mem.startsWith(u8, mnemonic_name, mnem_prefix)) continue;1752 if (!std.mem.startsWith(u8, mnemonic_name, mnem_prefix)) continue;
...@@ -1823,7 +1823,7 @@ pub const NullTerminatedString = enum(u32) {...@@ -1823,7 +1823,7 @@ pub const NullTerminatedString = enum(u32) {
1823 pub fn toSlice(nts: NullTerminatedString, mir: *const Mir) ?[:0]const u8 {1823 pub fn toSlice(nts: NullTerminatedString, mir: *const Mir) ?[:0]const u8 {
1824 if (nts == .none) return null;1824 if (nts == .none) return null;
1825 const string_bytes = mir.string_bytes[@backingInt(nts)..];1825 const string_bytes = mir.string_bytes[@backingInt(nts)..];
1826 return string_bytes[0..std.mem.indexOfScalar(u8, string_bytes, 0).? :0];1826 return string_bytes[0..std.mem.findScalar(u8, string_bytes, 0).? :0];
1827 }1827 }
1828};1828};
18291829
src/codegen/x86_64/abi.zig+1-1
...@@ -318,7 +318,7 @@ pub fn classifySystemV(ty: Type, zcu: *Zcu, target: *const std.Target, ctx: Cont...@@ -318,7 +318,7 @@ pub fn classifySystemV(ty: Type, zcu: *Zcu, target: *const std.Target, ctx: Cont
318 // byte isn't SSE or any other eightbyte isn't SSEUP, the whole argument318 // byte isn't SSE or any other eightbyte isn't SSEUP, the whole argument
319 // is passed in memory."319 // is passed in memory."
320 if (ty_size > 16 and (result[0] != .sse or320 if (ty_size > 16 and (result[0] != .sse or
321 std.mem.indexOfNone(Class, result[1..], &.{ .sseup, .none }) != null)) return Class.stack;321 std.mem.findNone(Class, result[1..], &.{ .sseup, .none }) != null)) return Class.stack;
322322
323 // "If SSEUP is not preceded by SSE or SSEUP, it is converted to SSE."323 // "If SSEUP is not preceded by SSE or SSEUP, it is converted to SSE."
324 for (&result, 0..) |*class, i| switch (class.*) {324 for (&result, 0..) |*class, i| switch (class.*) {
src/codegen/x86_64/encoder.zig+1-1
...@@ -1171,7 +1171,7 @@ fn expectEqualHexStrings(expected: []const u8, given: []const u8, assembly: []co...@@ -1171,7 +1171,7 @@ fn expectEqualHexStrings(expected: []const u8, given: []const u8, assembly: []co
1171 defer testing.allocator.free(expected_fmt);1171 defer testing.allocator.free(expected_fmt);
1172 const given_fmt = try std.fmt.allocPrint(testing.allocator, "{x}", .{given});1172 const given_fmt = try std.fmt.allocPrint(testing.allocator, "{x}", .{given});
1173 defer testing.allocator.free(given_fmt);1173 defer testing.allocator.free(given_fmt);
1174 const idx = std.mem.indexOfDiff(u8, expected_fmt, given_fmt).?;1174 const idx = std.mem.findDiff(u8, expected_fmt, given_fmt).?;
1175 const padding = try testing.allocator.alloc(u8, idx + 5);1175 const padding = try testing.allocator.alloc(u8, idx + 5);
1176 defer testing.allocator.free(padding);1176 defer testing.allocator.free(padding);
1177 @memset(padding, ' ');1177 @memset(padding, ' ');
src/libs/mingw/Preprocessor.zig+2-2
...@@ -15,7 +15,7 @@ const RawTokenList = std.ArrayList(Token);...@@ -15,7 +15,7 @@ const RawTokenList = std.ArrayList(Token);
15const ExpandBuf = std.ArrayList(Token);15const ExpandBuf = std.ArrayList(Token);
1616
17const Preprocessor = @This();17const Preprocessor = @This();
18const DefineMap = std.StringArrayHashMapUnmanaged(Macro);18const DefineMap = std.array_hash_map.String(Macro);
1919
20const GeneratedTokens = std.ArrayList(u8);20const GeneratedTokens = std.ArrayList(u8);
2121
...@@ -29,7 +29,7 @@ pub const Source = struct {...@@ -29,7 +29,7 @@ pub const Source = struct {
29 buf: []const u8,29 buf: []const u8,
30};30};
3131
32sources: std.StringArrayHashMapUnmanaged(Source) = .empty,32sources: std.array_hash_map.String(Source) = .empty,
3333
34arena: Allocator,34arena: Allocator,
35io: std.Io,35io: std.Io,
src/libs/mingw/def.zig+4-4
...@@ -61,7 +61,7 @@ pub const ModuleDefinition = struct {...@@ -61,7 +61,7 @@ pub const ModuleDefinition = struct {
61 // or ? for C++ functions). Vectorcall functions won't have any61 // or ? for C++ functions). Vectorcall functions won't have any
62 // fixed prefix, but the function base name will still be at least62 // fixed prefix, but the function base name will still be at least
63 // one char.63 // one char.
64 const name_len_without_at_suffix = std.mem.indexOfScalarPos(u8, e.name, 1, '@') orelse e.name.len;64 const name_len_without_at_suffix = std.mem.findScalarPos(u8, e.name, 1, '@') orelse e.name.len;
65 e.name = e.name[0..name_len_without_at_suffix];65 e.name = e.name[0..name_len_without_at_suffix];
66 }66 }
67 }67 }
...@@ -452,7 +452,7 @@ pub const Parser = struct {...@@ -452,7 +452,7 @@ pub const Parser = struct {
452 var ext_name_needs_underscore = false;452 var ext_name_needs_underscore = false;
453 if (self.machine_type == .I386) {453 if (self.machine_type == .I386) {
454 const is_decorated = isDecorated(name_tok.slice(self.tokenizer.source), self.module_definition_type);454 const is_decorated = isDecorated(name_tok.slice(self.tokenizer.source), self.module_definition_type);
455 const is_forward_target = ext_name_tok != null and std.mem.indexOfScalar(u8, name_tok.slice(self.tokenizer.source), '.') != null;455 const is_forward_target = ext_name_tok != null and std.mem.findScalar(u8, name_tok.slice(self.tokenizer.source), '.') != null;
456 name_needs_underscore = !is_decorated and !is_forward_target;456 name_needs_underscore = !is_decorated and !is_forward_target;
457457
458 if (ext_name_tok) |ext_name| {458 if (ext_name_tok) |ext_name| {
...@@ -578,9 +578,9 @@ pub const Parser = struct {...@@ -578,9 +578,9 @@ pub const Parser = struct {
578 // themselves can start with an underscore, while a second one still needs578 // themselves can start with an underscore, while a second one still needs
579 // to be added.579 // to be added.
580 if (std.mem.startsWith(u8, symbol, "@")) return true;580 if (std.mem.startsWith(u8, symbol, "@")) return true;
581 if (std.mem.indexOf(u8, symbol, "@@") != null) return true;581 if (std.mem.find(u8, symbol, "@@") != null) return true;
582 if (std.mem.startsWith(u8, symbol, "?")) return true;582 if (std.mem.startsWith(u8, symbol, "?")) return true;
583 if (module_definition_type != .mingw and std.mem.indexOfScalar(u8, symbol, '@') != null) return true;583 if (module_definition_type != .mingw and std.mem.findScalar(u8, symbol, '@') != null) return true;
584 return false;584 return false;
585 }585 }
586586
src/libs/mingw/implib.zig+1-1
...@@ -351,7 +351,7 @@ fn getNameType(...@@ -351,7 +351,7 @@ fn getNameType(
351 // the leading underscore. In MinGW on the other hand, a decorated351 // the leading underscore. In MinGW on the other hand, a decorated
352 // stdcall function still omits the underscore (IMPORT_NAME_NOPREFIX).352 // stdcall function still omits the underscore (IMPORT_NAME_NOPREFIX).
353 if (std.mem.startsWith(u8, ext_name, "_") and353 if (std.mem.startsWith(u8, ext_name, "_") and
354 std.mem.indexOfScalar(u8, ext_name, '@') != null and354 std.mem.findScalar(u8, ext_name, '@') != null and
355 module_definition_type != .mingw)355 module_definition_type != .mingw)
356 return .NAME;356 return .NAME;
357 if (!std.mem.eql(u8, symbol, ext_name))357 if (!std.mem.eql(u8, symbol, ext_name))
src/link/Coff.zig+7-7
...@@ -621,7 +621,7 @@ pub const LongNamesTable = struct {...@@ -621,7 +621,7 @@ pub const LongNamesTable = struct {
621 }621 }
622622
623 pub fn hash(_: Adapter, key: []const u8) u32 {623 pub fn hash(_: Adapter, key: []const u8) u32 {
624 assert(std.mem.indexOfScalar(u8, key, 0) == null);624 assert(std.mem.findScalar(u8, key, 0) == null);
625 return std.array_hash_map.hashString(key);625 return std.array_hash_map.hashString(key);
626 }626 }
627 };627 };
...@@ -711,7 +711,7 @@ pub const ExportTable = struct {...@@ -711,7 +711,7 @@ pub const ExportTable = struct {
711 }711 }
712712
713 pub fn hash(_: Adapter, key: []const u8) u32 {713 pub fn hash(_: Adapter, key: []const u8) u32 {
714 assert(std.mem.indexOfScalar(u8, key, 0) == null);714 assert(std.mem.findScalar(u8, key, 0) == null);
715 return std.array_hash_map.hashString(key);715 return std.array_hash_map.hashString(key);
716 }716 }
717 };717 };
...@@ -759,7 +759,7 @@ pub const ImportTable = struct {...@@ -759,7 +759,7 @@ pub const ImportTable = struct {
759 }759 }
760760
761 pub fn hash(_: Adapter, key: []const u8) u32 {761 pub fn hash(_: Adapter, key: []const u8) u32 {
762 assert(std.mem.indexOfScalar(u8, key, 0) == null);762 assert(std.mem.findScalar(u8, key, 0) == null);
763 return std.array_hash_map.hashString(key);763 return std.array_hash_map.hashString(key);
764 }764 }
765 };765 };
...@@ -822,7 +822,7 @@ pub const String = enum(u32) {...@@ -822,7 +822,7 @@ pub const String = enum(u32) {
822822
823 pub fn toSlice(s: String, coff: *Coff) [:0]const u8 {823 pub fn toSlice(s: String, coff: *Coff) [:0]const u8 {
824 const slice = coff.string_bytes.items[@backingInt(s)..];824 const slice = coff.string_bytes.items[@backingInt(s)..];
825 return slice[0..std.mem.indexOfScalar(u8, slice, 0).? :0];825 return slice[0..std.mem.findScalar(u8, slice, 0).? :0];
826 }826 }
827827
828 pub fn toOptional(s: String) String.Optional {828 pub fn toOptional(s: String) String.Optional {
...@@ -3535,7 +3535,7 @@ fn objectSectionParentName(coff: *Coff, name: []const u8) []const u8 {...@@ -3535,7 +3535,7 @@ fn objectSectionParentName(coff: *Coff, name: []const u8) []const u8 {
3535 // Otherwise, we want to keep the full name so that this sort can occur correctly when3535 // Otherwise, we want to keep the full name so that this sort can occur correctly when
3536 // the object is finally linked into an image.3536 // the object is finally linked into an image.
3537 return if (coff.isImage())3537 return if (coff.isImage())
3538 name[0 .. std.mem.indexOfScalar(u8, name, '$') orelse name.len]3538 name[0 .. std.mem.findScalar(u8, name, '$') orelse name.len]
3539 else3539 else
3540 name;3540 name;
3541}3541}
...@@ -5737,7 +5737,7 @@ fn reportUndefs(coff: *Coff, tid: Zcu.PerThread.Id) !void {...@@ -5737,7 +5737,7 @@ fn reportUndefs(coff: *Coff, tid: Zcu.PerThread.Id) !void {
5737 const gpa = comp.gpa;5737 const gpa = comp.gpa;
5738 const max_notes = 4;5738 const max_notes = 4;
57395739
5740 var undef_indices: std.ArrayListUnmanaged(u32) = .empty;5740 var undef_indices: std.ArrayList(u32) = .empty;
5741 for (coff.relocs.items, 0..) |reloc, reloc_i| {5741 for (coff.relocs.items, 0..) |reloc, reloc_i| {
5742 if (reloc.flags.free) continue;5742 if (reloc.flags.free) continue;
5743 const target_sym = reloc.target.get(coff);5743 const target_sym = reloc.target.get(coff);
...@@ -6987,7 +6987,7 @@ fn flushMoved(coff: *Coff, ni: MappedFile.Node.Index) !void {...@@ -6987,7 +6987,7 @@ fn flushMoved(coff: *Coff, ni: MappedFile.Node.Index) !void {
6987 continue;6987 continue;
69886988
6989 import_hint_name_index = @intCast(import_hint_name_align.forward(6989 import_hint_name_index = @intCast(import_hint_name_align.forward(
6990 std.mem.indexOfScalarPos(6990 std.mem.findScalarPos(
6991 u8,6991 u8,
6992 import_hint_name_slice,6992 import_hint_name_slice,
6993 import_hint_name_index,6993 import_hint_name_index,
src/link/Elf.zig+3-3
...@@ -2173,7 +2173,7 @@ fn sortInitFini(self: *Elf) !void {...@@ -2173,7 +2173,7 @@ fn sortInitFini(self: *Elf) !void {
2173 => is_init_fini = true,2173 => is_init_fini = true,
2174 else => {2174 else => {
2175 const name = self.getShString(shdr.sh_name);2175 const name = self.getShString(shdr.sh_name);
2176 is_ctor_dtor = mem.indexOf(u8, name, ".ctors") != null or mem.indexOf(u8, name, ".dtors") != null;2176 is_ctor_dtor = mem.find(u8, name, ".ctors") != null or mem.find(u8, name, ".dtors") != null;
2177 },2177 },
2178 }2178 }
2179 if (!is_init_fini and !is_ctor_dtor) continue;2179 if (!is_init_fini and !is_ctor_dtor) continue;
...@@ -3702,7 +3702,7 @@ fn shString(...@@ -3702,7 +3702,7 @@ fn shString(
3702 off: u32,3702 off: u32,
3703) [:0]const u8 {3703) [:0]const u8 {
3704 const slice = shstrtab[off..];3704 const slice = shstrtab[off..];
3705 return slice[0..mem.indexOfScalar(u8, slice, 0).? :0];3705 return slice[0..mem.findScalar(u8, slice, 0).? :0];
3706}3706}
37073707
3708pub fn insertShString(self: *Elf, name: [:0]const u8) error{OutOfMemory}!u32 {3708pub fn insertShString(self: *Elf, name: [:0]const u8) error{OutOfMemory}!u32 {
...@@ -4376,7 +4376,7 @@ fn createThunks(elf_file: *Elf, atom_list: *AtomList) !void {...@@ -4376,7 +4376,7 @@ fn createThunks(elf_file: *Elf, atom_list: *AtomList) !void {
43764376
4377pub fn stringTableLookup(strtab: []const u8, off: u32) [:0]const u8 {4377pub fn stringTableLookup(strtab: []const u8, off: u32) [:0]const u8 {
4378 const slice = strtab[off..];4378 const slice = strtab[off..];
4379 return slice[0..mem.indexOfScalar(u8, slice, 0).? :0];4379 return slice[0..mem.findScalar(u8, slice, 0).? :0];
4380}4380}
43814381
4382pub fn pwriteAll(elf_file: *Elf, bytes: []const u8, offset: u64) error{AlreadyReported}!void {4382pub fn pwriteAll(elf_file: *Elf, bytes: []const u8, offset: u64) error{AlreadyReported}!void {
src/link/Elf/Archive.zig+1-1
...@@ -118,7 +118,7 @@ pub fn parse(...@@ -118,7 +118,7 @@ pub fn parse(
118118
119pub fn stringTableLookup(strtab: []const u8, off: u32) [:'\n']const u8 {119pub fn stringTableLookup(strtab: []const u8, off: u32) [:'\n']const u8 {
120 const slice = strtab[off..];120 const slice = strtab[off..];
121 return slice[0..mem.indexOfScalar(u8, slice, '\n').? :'\n'];121 return slice[0..mem.findScalar(u8, slice, '\n').? :'\n'];
122}122}
123123
124pub fn setArHdr(opts: struct {124pub fn setArHdr(opts: struct {
src/link/Elf2.zig+1-1
...@@ -3010,7 +3010,7 @@ const StringTable = struct {...@@ -3010,7 +3010,7 @@ const StringTable = struct {
3010 }3010 }
30113011
3012 pub fn hash(_: Adapter, key: []const u8) u64 {3012 pub fn hash(_: Adapter, key: []const u8) u64 {
3013 assert(std.mem.indexOfScalar(u8, key, 0) == null);3013 assert(std.mem.findScalar(u8, key, 0) == null);
3014 return std.hash_map.hashString(key);3014 return std.hash_map.hashString(key);
3015 }3015 }
3016 };3016 };
src/link/MachO.zig+6-6
...@@ -1070,7 +1070,7 @@ fn isHoisted(self: *MachO, install_name: []const u8) bool {...@@ -1070,7 +1070,7 @@ fn isHoisted(self: *MachO, install_name: []const u8) bool {
1070 if (mem.startsWith(u8, dirname, "/usr/lib")) return true;1070 if (mem.startsWith(u8, dirname, "/usr/lib")) return true;
1071 if (eatPrefix(dirname, "/System/Library/Frameworks/")) |path| {1071 if (eatPrefix(dirname, "/System/Library/Frameworks/")) |path| {
1072 const basename = fs.path.basename(install_name);1072 const basename = fs.path.basename(install_name);
1073 if (mem.indexOfScalar(u8, path, '.')) |index| {1073 if (mem.findScalar(u8, path, '.')) |index| {
1074 if (mem.eql(u8, basename, path[0..index])) return true;1074 if (mem.eql(u8, basename, path[0..index])) return true;
1075 }1075 }
1076 }1076 }
...@@ -1739,14 +1739,14 @@ fn initSyntheticSections(self: *MachO) !void {...@@ -1739,14 +1739,14 @@ fn initSyntheticSections(self: *MachO) !void {
1739 });1739 });
1740 }1740 }
1741 } else if (eatPrefix(name, "section$start$")) |actual_name| {1741 } else if (eatPrefix(name, "section$start$")) |actual_name| {
1742 const sep = mem.indexOfScalar(u8, actual_name, '$').?; // TODO error rather than a panic1742 const sep = mem.findScalar(u8, actual_name, '$').?; // TODO error rather than a panic
1743 const segname = actual_name[0..sep]; // TODO check segname is valid1743 const segname = actual_name[0..sep]; // TODO check segname is valid
1744 const sectname = actual_name[sep + 1 ..]; // TODO check sectname is valid1744 const sectname = actual_name[sep + 1 ..]; // TODO check sectname is valid
1745 if (self.getSectionByName(segname, sectname) == null) {1745 if (self.getSectionByName(segname, sectname) == null) {
1746 _ = try self.addSection(segname, sectname, .{});1746 _ = try self.addSection(segname, sectname, .{});
1747 }1747 }
1748 } else if (eatPrefix(name, "section$end$")) |actual_name| {1748 } else if (eatPrefix(name, "section$end$")) |actual_name| {
1749 const sep = mem.indexOfScalar(u8, actual_name, '$').?; // TODO error rather than a panic1749 const sep = mem.findScalar(u8, actual_name, '$').?; // TODO error rather than a panic
1750 const segname = actual_name[0..sep]; // TODO check segname is valid1750 const segname = actual_name[0..sep]; // TODO check segname is valid
1751 const sectname = actual_name[sep + 1 ..]; // TODO check sectname is valid1751 const sectname = actual_name[sep + 1 ..]; // TODO check sectname is valid
1752 if (self.getSectionByName(segname, sectname) == null) {1752 if (self.getSectionByName(segname, sectname) == null) {
...@@ -1767,7 +1767,7 @@ fn getSegmentProt(segname: []const u8) macho.vm_prot_t {...@@ -1767,7 +1767,7 @@ fn getSegmentProt(segname: []const u8) macho.vm_prot_t {
1767fn getSegmentRank(segname: []const u8) u8 {1767fn getSegmentRank(segname: []const u8) u8 {
1768 if (mem.eql(u8, segname, "__PAGEZERO")) return 0x0;1768 if (mem.eql(u8, segname, "__PAGEZERO")) return 0x0;
1769 if (mem.eql(u8, segname, "__LINKEDIT")) return 0xf;1769 if (mem.eql(u8, segname, "__LINKEDIT")) return 0xf;
1770 if (mem.indexOf(u8, segname, "ZIG")) |_| return 0xe;1770 if (mem.find(u8, segname, "ZIG")) |_| return 0xe;
1771 if (mem.startsWith(u8, segname, "__TEXT")) return 0x1;1771 if (mem.startsWith(u8, segname, "__TEXT")) return 0x1;
1772 if (mem.startsWith(u8, segname, "__DATA_CONST")) return 0x2;1772 if (mem.startsWith(u8, segname, "__DATA_CONST")) return 0x2;
1773 if (mem.startsWith(u8, segname, "__DATA")) return 0x3;1773 if (mem.startsWith(u8, segname, "__DATA")) return 0x3;
...@@ -2342,7 +2342,7 @@ fn allocateSyntheticSymbols(self: *MachO) void {...@@ -2342,7 +2342,7 @@ fn allocateSyntheticSymbols(self: *MachO) void {
2342 }2342 }
2343 } else if (mem.startsWith(u8, name, "section$start$")) {2343 } else if (mem.startsWith(u8, name, "section$start$")) {
2344 const actual_name = name["section$start$".len..];2344 const actual_name = name["section$start$".len..];
2345 const sep = mem.indexOfScalar(u8, actual_name, '$').?; // TODO error rather than a panic2345 const sep = mem.findScalar(u8, actual_name, '$').?; // TODO error rather than a panic
2346 const segname = actual_name[0..sep];2346 const segname = actual_name[0..sep];
2347 const sectname = actual_name[sep + 1 ..];2347 const sectname = actual_name[sep + 1 ..];
2348 if (self.getSectionByName(segname, sectname)) |sect_id| {2348 if (self.getSectionByName(segname, sectname)) |sect_id| {
...@@ -2352,7 +2352,7 @@ fn allocateSyntheticSymbols(self: *MachO) void {...@@ -2352,7 +2352,7 @@ fn allocateSyntheticSymbols(self: *MachO) void {
2352 }2352 }
2353 } else if (mem.startsWith(u8, name, "section$end$")) {2353 } else if (mem.startsWith(u8, name, "section$end$")) {
2354 const actual_name = name["section$end$".len..];2354 const actual_name = name["section$end$".len..];
2355 const sep = mem.indexOfScalar(u8, actual_name, '$').?; // TODO error rather than a panic2355 const sep = mem.findScalar(u8, actual_name, '$').?; // TODO error rather than a panic
2356 const segname = actual_name[0..sep];2356 const segname = actual_name[0..sep];
2357 const sectname = actual_name[sep + 1 ..];2357 const sectname = actual_name[sep + 1 ..];
2358 if (self.getSectionByName(segname, sectname)) |sect_id| {2358 if (self.getSectionByName(segname, sectname)) |sect_id| {
src/link/MachO/Archive.zig+2-2
...@@ -45,7 +45,7 @@ pub fn unpack(self: *Archive, macho_file: *MachO, path: Path, handle_index: File...@@ -45,7 +45,7 @@ pub fn unpack(self: *Archive, macho_file: *MachO, path: Path, handle_index: File
45 const amt = try handle.readPositionalAll(io, buf, pos);45 const amt = try handle.readPositionalAll(io, buf, pos);
46 if (amt != len) return error.InputOutput;46 if (amt != len) return error.InputOutput;
47 pos += len;47 pos += len;
48 const actual_len = mem.indexOfScalar(u8, buf, @as(u8, 0)) orelse len;48 const actual_len = mem.findScalar(u8, buf, @as(u8, 0)) orelse len;
49 break :name buf[0..actual_len];49 break :name buf[0..actual_len];
50 }50 }
51 unreachable;51 unreachable;
...@@ -161,7 +161,7 @@ pub const ar_hdr = extern struct {...@@ -161,7 +161,7 @@ pub const ar_hdr = extern struct {
161 fn name(self: *const ar_hdr) ?[]const u8 {161 fn name(self: *const ar_hdr) ?[]const u8 {
162 const value = &self.ar_name;162 const value = &self.ar_name;
163 if (mem.startsWith(u8, value, "#1/")) return null;163 if (mem.startsWith(u8, value, "#1/")) return null;
164 const sentinel = mem.indexOfScalar(u8, value, '/') orelse value.len;164 const sentinel = mem.findScalar(u8, value, '/') orelse value.len;
165 return value[0..sentinel];165 return value[0..sentinel];
166 }166 }
167167
src/link/MachO/Symbol.zig+1-1
...@@ -43,7 +43,7 @@ pub fn isSymbolStab(symbol: Symbol, macho_file: *MachO) bool {...@@ -43,7 +43,7 @@ pub fn isSymbolStab(symbol: Symbol, macho_file: *MachO) bool {
4343
44pub fn isTlvInit(symbol: Symbol, macho_file: *MachO) bool {44pub fn isTlvInit(symbol: Symbol, macho_file: *MachO) bool {
45 const name = symbol.getName(macho_file);45 const name = symbol.getName(macho_file);
46 return std.mem.indexOf(u8, name, "$tlv$init") != null;46 return std.mem.find(u8, name, "$tlv$init") != null;
47}47}
4848
49pub fn weakRef(symbol: Symbol, macho_file: *MachO) bool {49pub fn weakRef(symbol: Symbol, macho_file: *MachO) bool {
src/link/MachO/dyld_info/Trie.zig+2-2
...@@ -54,7 +54,7 @@ fn putNode(self: *Trie, node_index: Node.Index, allocator: Allocator, label: []c...@@ -54,7 +54,7 @@ fn putNode(self: *Trie, node_index: Node.Index, allocator: Allocator, label: []c
54 // Check for match with edges from this node.54 // Check for match with edges from this node.
55 for (self.nodes.items(.edges)[node_index].items) |edge_index| {55 for (self.nodes.items(.edges)[node_index].items) |edge_index| {
56 const edge = &self.edges.items[edge_index];56 const edge = &self.edges.items[edge_index];
57 const match = mem.indexOfDiff(u8, edge.label, label) orelse return edge.node;57 const match = mem.findDiff(u8, edge.label, label) orelse return edge.node;
58 if (match == 0) continue;58 if (match == 0) continue;
59 if (match == edge.label.len) return self.putNode(edge.node, allocator, label[match..]);59 if (match == edge.label.len) return self.putNode(edge.node, allocator, label[match..]);
6060
...@@ -351,7 +351,7 @@ fn expectEqualHexStrings(expected: []const u8, given: []const u8) !void {...@@ -351,7 +351,7 @@ fn expectEqualHexStrings(expected: []const u8, given: []const u8) !void {
351 defer testing.allocator.free(expected_fmt);351 defer testing.allocator.free(expected_fmt);
352 const given_fmt = try std.fmt.allocPrint(testing.allocator, "{x}", .{given});352 const given_fmt = try std.fmt.allocPrint(testing.allocator, "{x}", .{given});
353 defer testing.allocator.free(given_fmt);353 defer testing.allocator.free(given_fmt);
354 const idx = mem.indexOfDiff(u8, expected_fmt, given_fmt).?;354 const idx = mem.findDiff(u8, expected_fmt, given_fmt).?;
355 const padding = try testing.allocator.alloc(u8, idx + 5);355 const padding = try testing.allocator.alloc(u8, idx + 5);
356 defer testing.allocator.free(padding);356 defer testing.allocator.free(padding);
357 @memset(padding, ' ');357 @memset(padding, ' ');
src/link/SpirV.zig+13-13
...@@ -25,10 +25,10 @@ const Mir = @import("../codegen/spirv/Mir.zig");...@@ -25,10 +25,10 @@ const Mir = @import("../codegen/spirv/Mir.zig");
25const Linker = @This();25const Linker = @This();
2626
27base: link.File,27base: link.File,
28fragments: std.AutoArrayHashMapUnmanaged(InternPool.Nav.Index, Mir) = .empty,28fragments: std.array_hash_map.Auto(InternPool.Nav.Index, Mir) = .empty,
29pending_navs: std.ArrayListUnmanaged(InternPool.Nav.Index) = .empty,29pending_navs: std.ArrayList(InternPool.Nav.Index) = .empty,
30entry_points: std.ArrayListUnmanaged(EntryPointDecl) = .empty,30entry_points: std.ArrayList(EntryPointDecl) = .empty,
31external_objects: std.ArrayListUnmanaged(ExternalObject) = .empty,31external_objects: std.ArrayList(ExternalObject) = .empty,
3232
33const EntryPointDecl = struct {33const EntryPointDecl = struct {
34 nav: InternPool.Nav.Index,34 nav: InternPool.Nav.Index,
...@@ -363,16 +363,16 @@ fn mergeFragments(linker: *Linker, gpa: Allocator, arena: Allocator) error{OutOf...@@ -363,16 +363,16 @@ fn mergeFragments(linker: *Linker, gpa: Allocator, arena: Allocator) error{OutOf
363 }363 }
364364
365 // Resolve Zig extern navs against external objects.365 // Resolve Zig extern navs against external objects.
366 var ext_id_offsets: std.ArrayListUnmanaged(Word) = .empty;366 var ext_id_offsets: std.ArrayList(Word) = .empty;
367 defer ext_id_offsets.deinit(gpa);367 defer ext_id_offsets.deinit(gpa);
368 try ext_id_offsets.ensureTotalCapacity(gpa, linker.external_objects.items.len);368 try ext_id_offsets.ensureTotalCapacity(gpa, linker.external_objects.items.len);
369369
370 var unresolved_extern_count: u32 = 0;370 var unresolved_extern_count: u32 = 0;
371 var resolved_ids: std.AutoArrayHashMapUnmanaged(Id, void) = .empty;371 var resolved_ids: std.array_hash_map.Auto(Id, void) = .empty;
372 defer resolved_ids.deinit(gpa);372 defer resolved_ids.deinit(gpa);
373373
374 if (maybe_ip) |ip| {374 if (maybe_ip) |ip| {
375 var extern_name_map: std.StringArrayHashMapUnmanaged(InternPool.Nav.Index) = .empty;375 var extern_name_map: std.array_hash_map.String(InternPool.Nav.Index) = .empty;
376 defer extern_name_map.deinit(gpa);376 defer extern_name_map.deinit(gpa);
377377
378 var nav_it = nav_final_ids.iterator();378 var nav_it = nav_final_ids.iterator();
...@@ -518,14 +518,14 @@ fn mergeZigFragments(...@@ -518,14 +518,14 @@ fn mergeZigFragments(
518 frag_infos: []const FragmentInfo,518 frag_infos: []const FragmentInfo,
519 nav_final_ids: *const std.AutoHashMapUnmanaged(InternPool.Nav.Index, Id),519 nav_final_ids: *const std.AutoHashMapUnmanaged(InternPool.Nav.Index, Id),
520 uav_final_ids: *const std.AutoHashMapUnmanaged(struct { InternPool.Index, spec.StorageClass }, Id),520 uav_final_ids: *const std.AutoHashMapUnmanaged(struct { InternPool.Index, spec.StorageClass }, Id),
521 resolved_ids: *const std.AutoArrayHashMapUnmanaged(Id, void),521 resolved_ids: *const std.array_hash_map.Auto(Id, void),
522 maybe_ip: ?*InternPool,522 maybe_ip: ?*InternPool,
523) error{OutOfMemory}!void {523) error{OutOfMemory}!void {
524 for (linker.fragments.values(), frag_infos) |*mir, frag_info| {524 for (linker.fragments.values(), frag_infos) |*mir, frag_info| {
525 var id_remap: std.AutoHashMapUnmanaged(Id, Id) = .empty;525 var id_remap: std.AutoHashMapUnmanaged(Id, Id) = .empty;
526 defer id_remap.deinit(gpa);526 defer id_remap.deinit(gpa);
527527
528 var resolved_local_ids: std.AutoArrayHashMapUnmanaged(Id, void) = .empty;528 var resolved_local_ids: std.array_hash_map.Auto(Id, void) = .empty;
529 defer resolved_local_ids.deinit(gpa);529 defer resolved_local_ids.deinit(gpa);
530530
531 for (mir.nav_refs) |ref| {531 for (mir.nav_refs) |ref| {
...@@ -569,7 +569,7 @@ fn remapFilteredInsts(...@@ -569,7 +569,7 @@ fn remapFilteredInsts(
569 id_offset: Word,569 id_offset: Word,
570 id_remap: *const std.AutoHashMapUnmanaged(Id, Id),570 id_remap: *const std.AutoHashMapUnmanaged(Id, Id),
571 parser: *BinaryModule.Parser,571 parser: *BinaryModule.Parser,
572 skip_ids: *const std.AutoArrayHashMapUnmanaged(Id, void),572 skip_ids: *const std.array_hash_map.Auto(Id, void),
573 mode: FilterMode,573 mode: FilterMode,
574) error{OutOfMemory}!void {574) error{OutOfMemory}!void {
575 if (words.len == 0) return;575 if (words.len == 0) return;
...@@ -887,9 +887,9 @@ fn appendExternalObjects(...@@ -887,9 +887,9 @@ fn appendExternalObjects(
887 has_linkage: *bool,887 has_linkage: *bool,
888 keep_entry_points: bool,888 keep_entry_points: bool,
889 is_obj: bool,889 is_obj: bool,
890 resolved_ids: *const std.AutoArrayHashMapUnmanaged(Id, void),890 resolved_ids: *const std.array_hash_map.Auto(Id, void),
891) error{OutOfMemory}!void {891) error{OutOfMemory}!void {
892 var export_map: std.StringArrayHashMapUnmanaged(Id) = .empty;892 var export_map: std.array_hash_map.String(Id) = .empty;
893 defer export_map.deinit(gpa);893 defer export_map.deinit(gpa);
894894
895 for (linker.external_objects.items, ext_id_offsets) |ext_obj, id_offset| {895 for (linker.external_objects.items, ext_id_offsets) |ext_obj, id_offset| {
...@@ -908,7 +908,7 @@ fn appendExternalObjects(...@@ -908,7 +908,7 @@ fn appendExternalObjects(
908 }908 }
909 for (per_obj_remaps) |*m| m.* = .empty;909 for (per_obj_remaps) |*m| m.* = .empty;
910910
911 var resolved_linkage_ids: std.AutoArrayHashMapUnmanaged(Id, void) = .empty;911 var resolved_linkage_ids: std.array_hash_map.Auto(Id, void) = .empty;
912 defer resolved_linkage_ids.deinit(gpa);912 defer resolved_linkage_ids.deinit(gpa);
913913
914 for (resolved_ids.keys()) |id| {914 for (resolved_ids.keys()) |id| {
src/link/SpirV/dedup_types.zig+2-2
...@@ -85,7 +85,7 @@ pub fn run(parser: *BinaryModule.Parser, binary: *BinaryModule) !void {...@@ -85,7 +85,7 @@ pub fn run(parser: *BinaryModule.Parser, binary: *BinaryModule) !void {
8585
86 for (inst.operands, 0..) |word, i| {86 for (inst.operands, 0..) |word, i| {
87 if (i == result_id_index) continue;87 if (i == result_id_index) continue;
88 if (std.mem.indexOfScalar(u16, id_offsets.items, @intCast(i)) != null) {88 if (std.mem.findScalar(u16, id_offsets.items, @intCast(i)) != null) {
89 const canonical = id_remap.get(@fromBackingInt(@intCast(word))) orelse @as(Id, @fromBackingInt(@intCast(word)));89 const canonical = id_remap.get(@fromBackingInt(@intCast(word))) orelse @as(Id, @fromBackingInt(@intCast(word)));
90 try key_words.append(gpa, @backingInt(canonical));90 try key_words.append(gpa, @backingInt(canonical));
91 } else {91 } else {
...@@ -182,7 +182,7 @@ pub fn run(parser: *BinaryModule.Parser, binary: *BinaryModule) !void {...@@ -182,7 +182,7 @@ pub fn run(parser: *BinaryModule.Parser, binary: *BinaryModule) !void {
182 } else null;182 } else null;
183183
184 for (inst_slice, 0..) |*word, i| {184 for (inst_slice, 0..) |*word, i| {
185 if (std.mem.indexOfScalar(u16, id_offsets.items, @intCast(i)) == null) continue;185 if (std.mem.findScalar(u16, id_offsets.items, @intCast(i)) == null) continue;
186 max_id = @max(max_id, word.*);186 max_id = @max(max_id, word.*);
187 if (maybe_result_id_index != null and i == maybe_result_id_index.?) continue;187 if (maybe_result_id_index != null and i == maybe_result_id_index.?) continue;
188188
src/link/SpirV/prune_unused.zig+1-1
...@@ -187,7 +187,7 @@ fn markAlive(...@@ -187,7 +187,7 @@ fn markAlive(
187 parser: *BinaryModule.Parser,187 parser: *BinaryModule.Parser,
188 binary: BinaryModule,188 binary: BinaryModule,
189 inst: BinaryModule.Instruction,189 inst: BinaryModule.Instruction,
190 alive: *std.DynamicBitSetUnmanaged,190 alive: *std.bit_set.Dynamic,
191 id_to_index: *const std.AutoHashMapUnmanaged(ResultId, u32),191 id_to_index: *const std.AutoHashMapUnmanaged(ResultId, u32),
192 code_offsets: *const std.ArrayList(usize),192 code_offsets: *const std.ArrayList(usize),
193 id_offset_buf: *std.ArrayList(u16),193 id_offset_buf: *std.ArrayList(u16),
src/link/Wasm.zig+4-4
...@@ -2539,14 +2539,14 @@ pub const String = enum(u32) {...@@ -2539,14 +2539,14 @@ pub const String = enum(u32) {
2539 }2539 }
25402540
2541 pub fn hash(_: @This(), adapted_key: []const u8) u64 {2541 pub fn hash(_: @This(), adapted_key: []const u8) u64 {
2542 assert(mem.indexOfScalar(u8, adapted_key, 0) == null);2542 assert(mem.findScalar(u8, adapted_key, 0) == null);
2543 return std.hash_map.hashString(adapted_key);2543 return std.hash_map.hashString(adapted_key);
2544 }2544 }
2545 };2545 };
25462546
2547 pub fn slice(index: String, wasm: *const Wasm) [:0]const u8 {2547 pub fn slice(index: String, wasm: *const Wasm) [:0]const u8 {
2548 const start_slice = wasm.string_bytes.items[@backingInt(index)..];2548 const start_slice = wasm.string_bytes.items[@backingInt(index)..];
2549 return start_slice[0..mem.indexOfScalar(u8, start_slice, 0).? :0];2549 return start_slice[0..mem.findScalar(u8, start_slice, 0).? :0];
2550 }2550 }
25512551
2552 pub fn toOptional(i: String) OptionalString {2552 pub fn toOptional(i: String) OptionalString {
...@@ -4332,7 +4332,7 @@ pub fn internOptionalString(wasm: *Wasm, optional_bytes: ?[]const u8) Allocator....@@ -4332,7 +4332,7 @@ pub fn internOptionalString(wasm: *Wasm, optional_bytes: ?[]const u8) Allocator.
4332}4332}
43334333
4334pub fn internString(wasm: *Wasm, bytes: []const u8) Allocator.Error!String {4334pub fn internString(wasm: *Wasm, bytes: []const u8) Allocator.Error!String {
4335 assert(mem.indexOfScalar(u8, bytes, 0) == null);4335 assert(mem.findScalar(u8, bytes, 0) == null);
4336 wasm.string_bytes_lock.lock();4336 wasm.string_bytes_lock.lock();
4337 defer wasm.string_bytes_lock.unlock();4337 defer wasm.string_bytes_lock.unlock();
4338 const gpa = wasm.base.comp.gpa;4338 const gpa = wasm.base.comp.gpa;
...@@ -4363,7 +4363,7 @@ pub fn internStringFmt(wasm: *Wasm, comptime format: []const u8, args: anytype)...@@ -4363,7 +4363,7 @@ pub fn internStringFmt(wasm: *Wasm, comptime format: []const u8, args: anytype)
4363}4363}
43644364
4365pub fn getExistingString(wasm: *const Wasm, bytes: []const u8) ?String {4365pub fn getExistingString(wasm: *const Wasm, bytes: []const u8) ?String {
4366 assert(mem.indexOfScalar(u8, bytes, 0) == null);4366 assert(mem.findScalar(u8, bytes, 0) == null);
4367 return wasm.string_table.getKeyAdapted(bytes, @as(String.TableIndexAdapter, .{4367 return wasm.string_table.getKeyAdapted(bytes, @as(String.TableIndexAdapter, .{
4368 .bytes = wasm.string_bytes.items,4368 .bytes = wasm.string_bytes.items,
4369 }));4369 }));
src/link/Wasm/Archive.zig+1-1
...@@ -45,7 +45,7 @@ const Header = extern struct {...@@ -45,7 +45,7 @@ const Header = extern struct {
4545
46 fn nameOrIndex(archive: Header) !NameOrIndex {46 fn nameOrIndex(archive: Header) !NameOrIndex {
47 const value = getValue(&archive.name);47 const value = getValue(&archive.name);
48 const slash_index = mem.indexOfScalar(u8, value, '/') orelse return error.MalformedArchive;48 const slash_index = mem.findScalar(u8, value, '/') orelse return error.MalformedArchive;
49 const len = value.len;49 const len = value.len;
50 if (slash_index == len - 1) {50 if (slash_index == len - 1) {
51 // Name stored directly51 // Name stored directly
src/link/Wasm/Flush.zig+3-3
...@@ -1925,7 +1925,7 @@ fn emitProducerSection(gpa: Allocator, binary_bytes: *ArrayList(u8)) !void {...@@ -1925,7 +1925,7 @@ fn emitProducerSection(gpa: Allocator, binary_bytes: *ArrayList(u8)) !void {
19251925
1926fn splitSegmentName(name: []const u8) struct { []const u8, []const u8 } {1926fn splitSegmentName(name: []const u8) struct { []const u8, []const u8 } {
1927 const start = @intFromBool(name.len >= 1 and name[0] == '.');1927 const start = @intFromBool(name.len >= 1 and name[0] == '.');
1928 const pivot = mem.indexOfScalarPos(u8, name, start, '.') orelse name.len;1928 const pivot = mem.findScalarPos(u8, name, start, '.') orelse name.len;
1929 return .{ name[0..pivot], name[pivot..] };1929 return .{ name[0..pivot], name[pivot..] };
1930}1930}
19311931
...@@ -2092,7 +2092,7 @@ fn emitTagNameTable(...@@ -2092,7 +2092,7 @@ fn emitTagNameTable(
2092 const ptr_size_bytes: usize = if (is64) 8 else 4;2092 const ptr_size_bytes: usize = if (is64) 8 else 4;
2093 try code.ensureUnusedCapacity(gpa, ptr_size_bytes * 2 * tag_name_offs.len);2093 try code.ensureUnusedCapacity(gpa, ptr_size_bytes * 2 * tag_name_offs.len);
2094 for (tag_name_offs) |off| {2094 for (tag_name_offs) |off| {
2095 const name_len: u32 = @intCast(mem.indexOfScalar(u8, tag_name_bytes[off..], 0).?);2095 const name_len: u32 = @intCast(mem.findScalar(u8, tag_name_bytes[off..], 0).?);
2096 if (is64) {2096 if (is64) {
2097 mem.writeInt(u64, code.addManyAsArrayAssumeCapacity(8), base + off, .little);2097 mem.writeInt(u64, code.addManyAsArrayAssumeCapacity(8), base + off, .little);
2098 mem.writeInt(u64, code.addManyAsArrayAssumeCapacity(8), name_len, .little);2098 mem.writeInt(u64, code.addManyAsArrayAssumeCapacity(8), name_len, .little);
...@@ -2119,7 +2119,7 @@ fn emitRelocatableNameTable(...@@ -2119,7 +2119,7 @@ fn emitRelocatableNameTable(
2119 try code.ensureUnusedCapacity(gpa, @as(usize, ptr_size) * 2 * name_offs.len);2119 try code.ensureUnusedCapacity(gpa, @as(usize, ptr_size) * 2 * name_offs.len);
2120 try relocs.ensureUnusedCapacity(gpa, name_offs.len);2120 try relocs.ensureUnusedCapacity(gpa, name_offs.len);
2121 for (name_offs) |off| {2121 for (name_offs) |off| {
2122 const name_len: u32 = @intCast(mem.indexOfScalar(u8, name_bytes[off..], 0).?);2122 const name_len: u32 = @intCast(mem.findScalar(u8, name_bytes[off..], 0).?);
2123 const reloc_offset = output_offset + @as(u32, @intCast(code.items.len - table_start));2123 const reloc_offset = output_offset + @as(u32, @intCast(code.items.len - table_start));
2124 switch (ptr_size) {2124 switch (ptr_size) {
2125 4 => {2125 4 => {
src/main.zig+3-3
...@@ -2148,7 +2148,7 @@ fn buildOutputType(...@@ -2148,7 +2148,7 @@ fn buildOutputType(
2148 preprocessor_arg[0] == '-' and2148 preprocessor_arg[0] == '-' and
2149 preprocessor_arg[2] != '-')2149 preprocessor_arg[2] != '-')
2150 {2150 {
2151 if (mem.indexOfScalar(u8, preprocessor_arg, '=')) |equals_pos| {2151 if (mem.findScalar(u8, preprocessor_arg, '=')) |equals_pos| {
2152 const key = preprocessor_arg[0..equals_pos];2152 const key = preprocessor_arg[0..equals_pos];
2153 const value = preprocessor_arg[equals_pos + 1 ..];2153 const value = preprocessor_arg[equals_pos + 1 ..];
2154 try preprocessor_args.append(key);2154 try preprocessor_args.append(key);
...@@ -2170,7 +2170,7 @@ fn buildOutputType(...@@ -2170,7 +2170,7 @@ fn buildOutputType(
2170 linker_arg[0] == '-' and2170 linker_arg[0] == '-' and
2171 linker_arg[2] != '-')2171 linker_arg[2] != '-')
2172 {2172 {
2173 if (mem.indexOfScalar(u8, linker_arg, '=')) |equals_pos| {2173 if (mem.findScalar(u8, linker_arg, '=')) |equals_pos| {
2174 const key = linker_arg[0..equals_pos];2174 const key = linker_arg[0..equals_pos];
2175 const value = linker_arg[equals_pos + 1 ..];2175 const value = linker_arg[equals_pos + 1 ..];
21762176
...@@ -2378,7 +2378,7 @@ fn buildOutputType(...@@ -2378,7 +2378,7 @@ fn buildOutputType(
2378 // Handle joined args like `--dependency-file=foo.d`.2378 // Handle joined args like `--dependency-file=foo.d`.
2379 // Must be prefixed with 1 or 2 dashes.2379 // Must be prefixed with 1 or 2 dashes.
2380 if (it.only_arg.len >= 3 and it.only_arg[0] == '-' and it.only_arg[2] != '-') {2380 if (it.only_arg.len >= 3 and it.only_arg[0] == '-' and it.only_arg[2] != '-') {
2381 if (mem.indexOfScalar(u8, it.only_arg, '=')) |equals_pos| {2381 if (mem.findScalar(u8, it.only_arg, '=')) |equals_pos| {
2382 const key = it.only_arg[0..equals_pos];2382 const key = it.only_arg[0..equals_pos];
2383 const value = it.only_arg[equals_pos + 1 ..];2383 const value = it.only_arg[equals_pos + 1 ..];
23842384
src/target.zig+2-2
...@@ -680,14 +680,14 @@ pub fn isDynamicAMDGCNFeature(target: *const std.Target, feature: std.Target.Cpu...@@ -680,14 +680,14 @@ pub fn isDynamicAMDGCNFeature(target: *const std.Target, feature: std.Target.Cpu
680 const feature_tag: std.Target.amdgcn.Feature = @fromBackingInt(@intCast(feature.index));680 const feature_tag: std.Target.amdgcn.Feature = @fromBackingInt(@intCast(feature.index));
681681
682 if (feature_tag == .sramecc) {682 if (feature_tag == .sramecc) {
683 if (std.mem.indexOfScalar(683 if (std.mem.findScalar(
684 *const std.Target.Cpu.Model,684 *const std.Target.Cpu.Model,
685 sramecc_only ++ xnack_or_sramecc,685 sramecc_only ++ xnack_or_sramecc,
686 target.cpu.model,686 target.cpu.model,
687 )) |_| return true;687 )) |_| return true;
688 }688 }
689 if (feature_tag == .xnack) {689 if (feature_tag == .xnack) {
690 if (std.mem.indexOfScalar(690 if (std.mem.findScalar(
691 *const std.Target.Cpu.Model,691 *const std.Target.Cpu.Model,
692 xnack_or_sramecc,692 xnack_or_sramecc,
693 target.cpu.model,693 target.cpu.model,
test/src/Cases.zig+2-2
...@@ -491,7 +491,7 @@ pub fn lowerToBuildSteps(...@@ -491,7 +491,7 @@ pub fn lowerToBuildSteps(
491491
492 for (self.cases.items) |case| {492 for (self.cases.items) |case| {
493 for (options.test_filters) |test_filter| {493 for (options.test_filters) |test_filter| {
494 if (std.mem.indexOf(u8, case.name, test_filter)) |_| break;494 if (std.mem.find(u8, case.name, test_filter)) |_| break;
495 } else if (options.test_filters.len > 0) continue;495 } else if (options.test_filters.len > 0) continue;
496496
497 if (case.case.? == .Error and options.skip_compile_errors) continue;497 if (case.case.? == .Error and options.skip_compile_errors) continue;
...@@ -524,7 +524,7 @@ pub fn lowerToBuildSteps(...@@ -524,7 +524,7 @@ pub fn lowerToBuildSteps(
524524
525 if (options.test_target_filters.len > 0) {525 if (options.test_target_filters.len > 0) {
526 for (options.test_target_filters) |filter| {526 for (options.test_target_filters) |filter| {
527 if (std.mem.indexOf(u8, triple_txt, filter) != null) break;527 if (std.mem.find(u8, triple_txt, filter) != null) break;
528 } else continue;528 } else continue;
529 }529 }
530530
test/src/Debugger.zig+2-2
...@@ -2384,13 +2384,13 @@ fn addTest(...@@ -2384,13 +2384,13 @@ fn addTest(
2384) void {2384) void {
2385 if (db.options.test_filters.len > 0) {2385 if (db.options.test_filters.len > 0) {
2386 for (db.options.test_filters) |test_filter| {2386 for (db.options.test_filters) |test_filter| {
2387 if (std.mem.indexOf(u8, name, test_filter) != null) break;2387 if (std.mem.find(u8, name, test_filter) != null) break;
2388 } else return;2388 } else return;
2389 }2389 }
2390 if (db.options.test_target_filters.len > 0) {2390 if (db.options.test_target_filters.len > 0) {
2391 const triple_txt = target.resolved.query.zigTriple(db.b.allocator) catch @panic("OOM");2391 const triple_txt = target.resolved.query.zigTriple(db.b.allocator) catch @panic("OOM");
2392 for (db.options.test_target_filters) |filter| {2392 for (db.options.test_target_filters) |filter| {
2393 if (std.mem.indexOf(u8, triple_txt, filter) != null) break;2393 if (std.mem.find(u8, triple_txt, filter) != null) break;
2394 } else return;2394 } else return;
2395 }2395 }
2396 const files_wf = db.b.addWriteFiles();2396 const files_wf = db.b.addWriteFiles();
test/src/ErrorTrace.zig+1-1
...@@ -82,7 +82,7 @@ fn addCaseConfig(...@@ -82,7 +82,7 @@ fn addCaseConfig(
82 });82 });
83 if (self.test_filters.len > 0) {83 if (self.test_filters.len > 0) {
84 for (self.test_filters) |test_filter| {84 for (self.test_filters) |test_filter| {
85 if (mem.indexOf(u8, annotated_case_name, test_filter)) |_| break;85 if (mem.find(u8, annotated_case_name, test_filter)) |_| break;
86 } else return;86 } else return;
87 }87 }
8888
test/src/Libc.zig+2-2
...@@ -49,7 +49,7 @@ pub fn addTarget(libc: *const Libc, target: std.Build.ResolvedTarget) void {...@@ -49,7 +49,7 @@ pub fn addTarget(libc: *const Libc, target: std.Build.ResolvedTarget) void {
49 if (libc.options.test_target_filters.len > 0) {49 if (libc.options.test_target_filters.len > 0) {
50 const triple_txt = target.query.zigTriple(libc.b.allocator) catch @panic("OOM");50 const triple_txt = target.query.zigTriple(libc.b.allocator) catch @panic("OOM");
51 for (libc.options.test_target_filters) |filter| {51 for (libc.options.test_target_filters) |filter| {
52 if (std.mem.indexOf(u8, triple_txt, filter)) |_| break;52 if (std.mem.find(u8, triple_txt, filter)) |_| break;
53 } else return;53 } else return;
54 }54 }
5555
...@@ -82,7 +82,7 @@ pub fn addTarget(libc: *const Libc, target: std.Build.ResolvedTarget) void {...@@ -82,7 +82,7 @@ pub fn addTarget(libc: *const Libc, target: std.Build.ResolvedTarget) void {
8282
83 const annotated_case_name = libc.b.fmt("run libc-test {s} ({t})", .{ test_case.name, optimize });83 const annotated_case_name = libc.b.fmt("run libc-test {s} ({t})", .{ test_case.name, optimize });
84 for (libc.options.test_filters) |test_filter| {84 for (libc.options.test_filters) |test_filter| {
85 if (std.mem.indexOf(u8, annotated_case_name, test_filter)) |_| break;85 if (std.mem.find(u8, annotated_case_name, test_filter)) |_| break;
86 } else if (libc.options.test_filters.len > 0) continue;86 } else if (libc.options.test_filters.len > 0) continue;
8787
88 const mod = libc.b.createModule(.{88 const mod = libc.b.createModule(.{
test/src/Link.zig+1-1
...@@ -8,7 +8,7 @@ use_lld: bool,...@@ -8,7 +8,7 @@ use_lld: bool,
8link_libc: bool,8link_libc: bool,
9test_filters: []const []const u8,9test_filters: []const []const u8,
10update_step: ?*Step.UpdateSourceFiles,10update_step: ?*Step.UpdateSourceFiles,
11updated_snapshots: std.StringArrayHashMapUnmanaged(void),11updated_snapshots: std.array_hash_map.String(void),
12max_rss: usize,12max_rss: usize,
1313
14pub fn includeTest(self: *Link, prefix: []const u8) ?Case {14pub fn includeTest(self: *Link, prefix: []const u8) ?Case {
test/src/LlvmIr.zig+2-2
...@@ -77,14 +77,14 @@ pub fn addCase(self: *LlvmIr, case: TestCase) void {...@@ -77,14 +77,14 @@ pub fn addCase(self: *LlvmIr, case: TestCase) void {
77 if (self.options.test_target_filters.len > 0) {77 if (self.options.test_target_filters.len > 0) {
78 const triple_txt = target.query.zigTriple(self.b.allocator) catch @panic("OOM");78 const triple_txt = target.query.zigTriple(self.b.allocator) catch @panic("OOM");
79 for (self.options.test_target_filters) |filter| {79 for (self.options.test_target_filters) |filter| {
80 if (std.mem.indexOf(u8, triple_txt, filter) != null) break;80 if (std.mem.find(u8, triple_txt, filter) != null) break;
81 } else return;81 } else return;
82 }82 }
8383
84 const name = std.fmt.allocPrint(self.b.allocator, "check llvm-ir {s}", .{case.name}) catch @panic("OOM");84 const name = std.fmt.allocPrint(self.b.allocator, "check llvm-ir {s}", .{case.name}) catch @panic("OOM");
85 if (self.options.test_filters.len > 0) {85 if (self.options.test_filters.len > 0) {
86 for (self.options.test_filters) |filter| {86 for (self.options.test_filters) |filter| {
87 if (std.mem.indexOf(u8, name, filter) != null) break;87 if (std.mem.find(u8, name, filter) != null) break;
88 } else return;88 } else return;
89 }89 }
9090
test/src/RunTranslatedC.zig+1-1
...@@ -68,7 +68,7 @@ pub fn addCase(self: *RunTranslatedCContext, case: *const TestCase) void {...@@ -68,7 +68,7 @@ pub fn addCase(self: *RunTranslatedCContext, case: *const TestCase) void {
6868
69 const annotated_case_name = fmt.allocPrint(self.b.allocator, "run-translated-c {s}", .{case.name}) catch unreachable;69 const annotated_case_name = fmt.allocPrint(self.b.allocator, "run-translated-c {s}", .{case.name}) catch unreachable;
70 for (self.test_filters) |test_filter| {70 for (self.test_filters) |test_filter| {
71 if (mem.indexOf(u8, annotated_case_name, test_filter)) |_| break;71 if (mem.find(u8, annotated_case_name, test_filter)) |_| break;
72 } else if (self.test_filters.len > 0) return;72 } else if (self.test_filters.len > 0) return;
7373
74 const write_src = b.addWriteFiles();74 const write_src = b.addWriteFiles();
test/src/StackTrace.zig+1-1
...@@ -200,7 +200,7 @@ fn addCaseInstance(...@@ -200,7 +200,7 @@ fn addCaseInstance(
200 });200 });
201 if (self.test_filters.len > 0) {201 if (self.test_filters.len > 0) {
202 for (self.test_filters) |test_filter| {202 for (self.test_filters) |test_filter| {
203 if (mem.indexOf(u8, annotated_case_name, test_filter)) |_| break;203 if (mem.find(u8, annotated_case_name, test_filter)) |_| break;
204 } else return;204 } else return;
205 }205 }
206206
test/src/TranslateC.zig+2-2
...@@ -90,7 +90,7 @@ pub fn addCase(self: *TranslateCContext, case: *const TestCase) void {...@@ -90,7 +90,7 @@ pub fn addCase(self: *TranslateCContext, case: *const TestCase) void {
90 const translate_c_cmd = "translate-c";90 const translate_c_cmd = "translate-c";
91 const annotated_case_name = fmt.allocPrint(self.b.allocator, "{s} {s}", .{ translate_c_cmd, case.name }) catch unreachable;91 const annotated_case_name = fmt.allocPrint(self.b.allocator, "{s} {s}", .{ translate_c_cmd, case.name }) catch unreachable;
92 for (self.test_filters) |test_filter| {92 for (self.test_filters) |test_filter| {
93 if (mem.indexOf(u8, annotated_case_name, test_filter)) |_| break;93 if (mem.find(u8, annotated_case_name, test_filter)) |_| break;
94 } else if (self.test_filters.len > 0) return;94 } else if (self.test_filters.len > 0) return;
9595
96 const target = b.resolveTargetQuery(case.target);96 const target = b.resolveTargetQuery(case.target);
...@@ -99,7 +99,7 @@ pub fn addCase(self: *TranslateCContext, case: *const TestCase) void {...@@ -99,7 +99,7 @@ pub fn addCase(self: *TranslateCContext, case: *const TestCase) void {
99 const triple_txt = target.query.zigTriple(b.allocator) catch @panic("OOM");99 const triple_txt = target.query.zigTriple(b.allocator) catch @panic("OOM");
100100
101 for (self.test_target_filters) |filter| {101 for (self.test_target_filters) |filter| {
102 if (std.mem.indexOf(u8, triple_txt, filter) != null) break;102 if (std.mem.find(u8, triple_txt, filter) != null) break;
103 } else return;103 } else return;
104 }104 }
105105
test/src/convert-stack-trace.zig+3-3
...@@ -52,13 +52,13 @@ pub fn main(init: std.process.Init) !void {...@@ -52,13 +52,13 @@ pub fn main(init: std.process.Init) !void {
52 continue;52 continue;
53 }53 }
5454
55 const src_pos_end = std.mem.indexOf(u8, in_line, ": 0x") orelse {55 const src_pos_end = std.mem.find(u8, in_line, ": 0x") orelse {
56 try w.writeAll(in_line);56 try w.writeAll(in_line);
57 continue;57 continue;
58 };58 };
59 const src_pos_start = b: {59 const src_pos_start = b: {
60 const postfix = ".zig:";60 const postfix = ".zig:";
61 const postfix_index = std.mem.lastIndexOf(u8, in_line[0..src_pos_end], postfix) orelse {61 const postfix_index = std.mem.findLast(u8, in_line[0..src_pos_end], postfix) orelse {
62 try w.writeAll(in_line);62 try w.writeAll(in_line);
63 continue;63 continue;
64 };64 };
...@@ -89,7 +89,7 @@ pub fn main(init: std.process.Init) !void {...@@ -89,7 +89,7 @@ pub fn main(init: std.process.Init) !void {
89 // ...with that first '_' being replaced by its basename.89 // ...with that first '_' being replaced by its basename.
9090
91 const src_path = in_line[0..src_pos_start];91 const src_path = in_line[0..src_pos_start];
92 const basename_start = if (std.mem.lastIndexOfAny(u8, src_path, "/\\")) |i| i + 1 else 0;92 const basename_start = if (std.mem.findLastAny(u8, src_path, "/\\")) |i| i + 1 else 0;
93 const symbol_start = addr_end + " in ".len;93 const symbol_start = addr_end + " in ".len;
94 try w.writeAll(in_line[basename_start..src_pos_end]);94 try w.writeAll(in_line[basename_start..src_pos_end]);
95 try w.writeAll(": [address] in ");95 try w.writeAll(": [address] in ");
test/tests.zig+9-9
...@@ -2542,13 +2542,13 @@ pub fn addStandaloneTests(...@@ -2542,13 +2542,13 @@ pub fn addStandaloneTests(
2542 .enable_ios_sdk = enable_ios_sdk,2542 .enable_ios_sdk = enable_ios_sdk,
2543 .enable_macos_sdk = enable_macos_sdk,2543 .enable_macos_sdk = enable_macos_sdk,
2544 .enable_symlinks_windows = enable_symlinks_windows,2544 .enable_symlinks_windows = enable_symlinks_windows,
2545 .simple_skip_debug = mem.indexOfScalar(OptimizeMode, optimize_modes, .debug) == null,2545 .simple_skip_debug = mem.findScalar(OptimizeMode, optimize_modes, .debug) == null,
2546 .simple_skip_release_safe = mem.indexOfScalar(OptimizeMode, optimize_modes, .safe) == null,2546 .simple_skip_release_safe = mem.findScalar(OptimizeMode, optimize_modes, .safe) == null,
2547 .simple_skip_release_fast = mem.indexOfScalar(OptimizeMode, optimize_modes, .fast) == null,2547 .simple_skip_release_fast = mem.findScalar(OptimizeMode, optimize_modes, .fast) == null,
2548 .simple_skip_release_small = mem.indexOfScalar(OptimizeMode, optimize_modes, .small) == null,2548 .simple_skip_release_small = mem.findScalar(OptimizeMode, optimize_modes, .small) == null,
2549 });2549 });
2550 const test_cases_dep_step = test_cases_dep.builder.default_step;2550 const test_cases_dep_step = test_cases_dep.builder.default_step;
2551 test_cases_dep_step.name = b.dupe(test_cases_dep_name);2551 test_cases_dep_step.name = b.graph.dupeString(test_cases_dep_name);
2552 step.dependOn(test_cases_dep.builder.default_step);2552 step.dependOn(test_cases_dep.builder.default_step);
2553 }2553 }
2554 return step;2554 return step;
...@@ -2862,7 +2862,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {...@@ -2862,7 +2862,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
28622862
2863 if (options.test_target_filters.len > 0) {2863 if (options.test_target_filters.len > 0) {
2864 for (options.test_target_filters) |filter| {2864 for (options.test_target_filters) |filter| {
2865 if (std.mem.indexOf(u8, triple_txt, filter) != null) break;2865 if (std.mem.find(u8, triple_txt, filter) != null) break;
2866 } else continue;2866 } else continue;
2867 }2867 }
28682868
...@@ -3160,7 +3160,7 @@ pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step {...@@ -3160,7 +3160,7 @@ pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step {
31603160
3161 if (options.test_target_filters.len > 0) {3161 if (options.test_target_filters.len > 0) {
3162 for (options.test_target_filters) |filter| {3162 for (options.test_target_filters) |filter| {
3163 if (std.mem.indexOf(u8, triple_txt, filter) != null) break;3163 if (std.mem.find(u8, triple_txt, filter) != null) break;
3164 } else continue;3164 } else continue;
3165 }3165 }
31663166
...@@ -3249,7 +3249,7 @@ pub fn addLinkTests(b: *std.Build, options: LinkTestOptions) *Step {...@@ -3249,7 +3249,7 @@ pub fn addLinkTests(b: *std.Build, options: LinkTestOptions) *Step {
32493249
3250 if (options.test_target_filters.len > 0) {3250 if (options.test_target_filters.len > 0) {
3251 for (options.test_target_filters) |filter| {3251 for (options.test_target_filters) |filter| {
3252 if (std.mem.indexOf(u8, triple_txt, filter) != null) break;3252 if (std.mem.find(u8, triple_txt, filter) != null) break;
3253 } else continue;3253 } else continue;
3254 }3254 }
32553255
...@@ -3374,7 +3374,7 @@ pub fn addIncrementalTests(b: *std.Build, test_step: *Step, test_filters: []cons...@@ -3374,7 +3374,7 @@ pub fn addIncrementalTests(b: *std.Build, test_step: *Step, test_filters: []cons
3374 if (std.mem.endsWith(u8, entry.basename, ".swp")) continue;3374 if (std.mem.endsWith(u8, entry.basename, ".swp")) continue;
33753375
3376 for (test_filters) |test_filter| {3376 for (test_filters) |test_filter| {
3377 if (std.mem.indexOf(u8, entry.path, test_filter)) |_| break;3377 if (std.mem.find(u8, entry.path, test_filter)) |_| break;
3378 } else if (test_filters.len > 0) continue;3378 } else if (test_filters.len > 0) continue;
33793379
3380 switch (entry.kind) {3380 switch (entry.kind) {
tools/docgen.zig+2-2
...@@ -712,10 +712,10 @@ fn tokenizeAndPrintRaw(...@@ -712,10 +712,10 @@ fn tokenizeAndPrintRaw(
712 next_tok_is_fn = false;712 next_tok_is_fn = false;
713713
714 const token = tokenizer.next();714 const token = tokenizer.next();
715 if (mem.indexOf(u8, src[index..token.loc.start], "//")) |comment_start_off| {715 if (mem.find(u8, src[index..token.loc.start], "//")) |comment_start_off| {
716 // render one comment716 // render one comment
717 const comment_start = index + comment_start_off;717 const comment_start = index + comment_start_off;
718 const comment_end_off = mem.indexOf(u8, src[comment_start..token.loc.start], "\n");718 const comment_end_off = mem.find(u8, src[comment_start..token.loc.start], "\n");
719 const comment_end = if (comment_end_off) |o| comment_start + o else token.loc.start;719 const comment_end = if (comment_end_off) |o| comment_start + o else token.loc.start;
720720
721 try writeEscapedLines(out, src[index..comment_start]);721 try writeEscapedLines(out, src[index..comment_start]);
tools/doctest.zig+8-8
...@@ -383,7 +383,7 @@ fn printOutput(...@@ -383,7 +383,7 @@ fn printOutput(
383 fatal("example compile crashed", .{});383 fatal("example compile crashed", .{});
384 },384 },
385 }385 }
386 if (mem.indexOf(u8, result.stderr, error_match) == null) {386 if (mem.find(u8, result.stderr, error_match) == null) {
387 print("{s}\nExpected to find '{s}' in stderr\n", .{ result.stderr, error_match });387 print("{s}\nExpected to find '{s}' in stderr\n", .{ result.stderr, error_match });
388 fatal("example did not have expected compile error", .{});388 fatal("example did not have expected compile error", .{});
389 }389 }
...@@ -438,7 +438,7 @@ fn printOutput(...@@ -438,7 +438,7 @@ fn printOutput(
438 fatal("example compile crashed", .{});438 fatal("example compile crashed", .{});
439 },439 },
440 }440 }
441 if (mem.indexOf(u8, result.stderr, error_match) == null) {441 if (mem.find(u8, result.stderr, error_match) == null) {
442 print("{s}\nExpected to find '{s}' in stderr\n", .{ result.stderr, error_match });442 print("{s}\nExpected to find '{s}' in stderr\n", .{ result.stderr, error_match });
443 fatal("example did not have expected runtime safety error message", .{});443 fatal("example did not have expected runtime safety error message", .{});
444 }444 }
...@@ -513,7 +513,7 @@ fn printOutput(...@@ -513,7 +513,7 @@ fn printOutput(
513 fatal("example compile crashed", .{});513 fatal("example compile crashed", .{});
514 },514 },
515 }515 }
516 if (mem.indexOf(u8, result.stderr, error_match) == null) {516 if (mem.find(u8, result.stderr, error_match) == null) {
517 print("{s}\nExpected to find '{s}' in stderr\n", .{ result.stderr, error_match });517 print("{s}\nExpected to find '{s}' in stderr\n", .{ result.stderr, error_match });
518 fatal("example did not have expected compile error message", .{});518 fatal("example did not have expected compile error message", .{});
519 }519 }
...@@ -623,10 +623,10 @@ fn tokenizeAndPrint(arena: Allocator, out: *Writer, raw_src: []const u8) !void {...@@ -623,10 +623,10 @@ fn tokenizeAndPrint(arena: Allocator, out: *Writer, raw_src: []const u8) !void {
623 next_tok_is_fn = false;623 next_tok_is_fn = false;
624624
625 const token = tokenizer.next();625 const token = tokenizer.next();
626 if (mem.indexOf(u8, src[index..token.loc.start], "//")) |comment_start_off| {626 if (mem.find(u8, src[index..token.loc.start], "//")) |comment_start_off| {
627 // render one comment627 // render one comment
628 const comment_start = index + comment_start_off;628 const comment_start = index + comment_start_off;
629 const comment_end_off = mem.indexOf(u8, src[comment_start..token.loc.start], "\n");629 const comment_end_off = mem.find(u8, src[comment_start..token.loc.start], "\n");
630 const comment_end = if (comment_end_off) |o| comment_start + o else token.loc.start;630 const comment_end = if (comment_end_off) |o| comment_start + o else token.loc.start;
631631
632 try writeEscapedLines(out, src[index..comment_start]);632 try writeEscapedLines(out, src[index..comment_start]);
...@@ -870,13 +870,13 @@ const Code = struct {...@@ -870,13 +870,13 @@ const Code = struct {
870};870};
871871
872fn stripManifest(source_bytes: []const u8) []const u8 {872fn stripManifest(source_bytes: []const u8) []const u8 {
873 const manifest_start = mem.lastIndexOf(u8, source_bytes, "\n\n// ") orelse873 const manifest_start = mem.findLast(u8, source_bytes, "\n\n// ") orelse
874 fatal("missing manifest comment", .{});874 fatal("missing manifest comment", .{});
875 return source_bytes[0 .. manifest_start + 1];875 return source_bytes[0 .. manifest_start + 1];
876}876}
877877
878fn parseManifest(arena: Allocator, source_bytes: []const u8) !Code {878fn parseManifest(arena: Allocator, source_bytes: []const u8) !Code {
879 const manifest_start = mem.lastIndexOf(u8, source_bytes, "\n\n// ") orelse879 const manifest_start = mem.findLast(u8, source_bytes, "\n\n// ") orelse
880 fatal("missing manifest comment", .{});880 fatal("missing manifest comment", .{});
881 var it = mem.tokenizeScalar(u8, source_bytes[manifest_start..], '\n');881 var it = mem.tokenizeScalar(u8, source_bytes[manifest_start..], '\n');
882 const first_line = skipPrefix(it.next().?);882 const first_line = skipPrefix(it.next().?);
...@@ -1104,7 +1104,7 @@ fn termColor(allocator: Allocator, input: []const u8) ![]u8 {...@@ -1104,7 +1104,7 @@ fn termColor(allocator: Allocator, input: []const u8) ![]u8 {
11041104
1105// Returns true if number is in slice.1105// Returns true if number is in slice.
1106fn in(slice: []const u8, number: u8) bool {1106fn in(slice: []const u8, number: u8) bool {
1107 return mem.indexOfScalar(u8, slice, number) != null;1107 return mem.findScalar(u8, slice, number) != null;
1108}1108}
11091109
1110fn run(1110fn run(
tools/fetch_them_macos_headers.zig+2-2
...@@ -187,8 +187,8 @@ fn fetchTarget(...@@ -187,8 +187,8 @@ fn fetchTarget(
187187
188 var it = mem.splitScalar(u8, headers_list_str, '\n');188 var it = mem.splitScalar(u8, headers_list_str, '\n');
189 while (it.next()) |line| {189 while (it.next()) |line| {
190 if (mem.lastIndexOf(u8, line, "clang") != null) continue;190 if (mem.findLast(u8, line, "clang") != null) continue;
191 if (mem.lastIndexOf(u8, line, prefix[0..])) |idx| {191 if (mem.findLast(u8, line, prefix[0..])) |idx| {
192 const out_rel_path = line[idx + prefix.len + 1 ..];192 const out_rel_path = line[idx + prefix.len + 1 ..];
193 const out_rel_path_stripped = mem.trim(u8, out_rel_path, " \\");193 const out_rel_path_stripped = mem.trim(u8, out_rel_path, " \\");
194 const dirname = Dir.path.dirname(out_rel_path_stripped) orelse ".";194 const dirname = Dir.path.dirname(out_rel_path_stripped) orelse ".";
tools/incr-check.zig+3-3
...@@ -450,7 +450,7 @@ const Eval = struct {...@@ -450,7 +450,7 @@ const Eval = struct {
450 const raw_filename = eb.nullTerminatedString(src.src_path);450 const raw_filename = eb.nullTerminatedString(src.src_path);
451 // We need to replace backslashes for consistency between platforms.451 // We need to replace backslashes for consistency between platforms.
452 const filename = name: {452 const filename = name: {
453 if (std.mem.indexOfScalar(u8, raw_filename, '\\') == null) break :name raw_filename;453 if (std.mem.findScalar(u8, raw_filename, '\\') == null) break :name raw_filename;
454 const copied = try eval.arena.dupe(u8, raw_filename);454 const copied = try eval.arena.dupe(u8, raw_filename);
455 std.mem.replaceScalar(u8, copied, '\\', '/');455 std.mem.replaceScalar(u8, copied, '\\', '/');
456 break :name copied;456 break :name copied;
...@@ -777,7 +777,7 @@ const Case = struct {...@@ -777,7 +777,7 @@ const Case = struct {
777 .backend = backend,777 .backend = backend,
778 });778 });
779 } else if (std.mem.eql(u8, key, "module")) {779 } else if (std.mem.eql(u8, key, "module")) {
780 const split_idx = std.mem.indexOfScalar(u8, val, '=') orelse780 const split_idx = std.mem.findScalar(u8, val, '=') orelse
781 fatal("line {d}: module does not include file", .{line_n});781 fatal("line {d}: module does not include file", .{line_n});
782 const name = val[0..split_idx];782 const name = val[0..split_idx];
783 const file = val[split_idx + 1 ..];783 const file = val[split_idx + 1 ..];
...@@ -983,7 +983,7 @@ fn rand64(io: Io) u64 {...@@ -983,7 +983,7 @@ fn rand64(io: Io) u64 {
983fn parseTargetQueryAndBackend(input_str: []const u8, err_prefix: []const u8) struct { std.Target.Query, Backend } {983fn parseTargetQueryAndBackend(input_str: []const u8, err_prefix: []const u8) struct { std.Target.Query, Backend } {
984 const fatal = std.process.fatal;984 const fatal = std.process.fatal;
985985
986 const split_idx = std.mem.lastIndexOfScalar(u8, input_str, '-') orelse986 const split_idx = std.mem.findScalarLast(u8, input_str, '-') orelse
987 fatal("{s}target does not include backend", .{err_prefix});987 fatal("{s}target does not include backend", .{err_prefix});
988988
989 const query = input_str[0..split_idx];989 const query = input_str[0..split_idx];
tools/update_clang_options.zig+1-1
...@@ -599,7 +599,7 @@ const known_options = [_]KnownOpt{...@@ -599,7 +599,7 @@ const known_options = [_]KnownOpt{
599const blacklisted_options = [_][]const u8{};599const blacklisted_options = [_][]const u8{};
600600
601fn knownOption(name: []const u8) ?[]const u8 {601fn knownOption(name: []const u8) ?[]const u8 {
602 const chopped_name = if (std.mem.indexOfScalar(u8, name, '=')) |idx| name[0..idx] else name;602 const chopped_name = if (std.mem.findScalar(u8, name, '=')) |idx| name[0..idx] else name;
603 for (known_options) |item| {603 for (known_options) |item| {
604 if (std.mem.eql(u8, chopped_name, item.name)) {604 if (std.mem.eql(u8, chopped_name, item.name)) {
605 return item.ident;605 return item.ident;
tools/update_crc_catalog.zig+1-1
...@@ -99,7 +99,7 @@ fn @"i like cheese"(arena: std.mem.Allocator, io: Io, args: []const []const u8)...@@ -99,7 +99,7 @@ fn @"i like cheese"(arena: std.mem.Allocator, io: Io, args: []const []const u8)
9999
100 var it = mem.splitSequence(u8, line, " ");100 var it = mem.splitSequence(u8, line, " ");
101 while (it.next()) |property| {101 while (it.next()) |property| {
102 const i = mem.indexOf(u8, property, "=").?;102 const i = mem.find(u8, property, "=").?;
103 const key = property[0..i];103 const key = property[0..i];
104 const value = property[i + 1 ..];104 const value = property[i + 1 ..];
105 if (mem.eql(u8, key, "width")) {105 if (mem.eql(u8, key, "width")) {