diff --git a/lib/build-web/time_report.zig b/lib/build-web/time_report.zig
index f6e641432c93f7c2dc60cc710903ee907f25c626..042919e301b27d9c0705ed50ef057ad2f15b0d96 100644
--- a/lib/build-web/time_report.zig
+++ b/lib/build-web/time_report.zig
@@ -84,7 +84,7 @@ pub fn compileResultMessage(msg_bytes: []u8) error{ OutOfMemory, WriteFailed }!v
defer gpa.free(slowest_decls);
for (slowest_files) |*file_out| {
- const i = std.mem.indexOfScalar(u8, trailing, 0) orelse @panic("malformed CompileResult message");
+ const i = std.mem.findScalar(u8, trailing, 0) orelse @panic("malformed CompileResult message");
file_out.* = .{
.name = trailing[0..i],
.ns_sema = 0,
@@ -95,7 +95,7 @@ pub fn compileResultMessage(msg_bytes: []u8) error{ OutOfMemory, WriteFailed }!v
}
for (slowest_decls) |*decl_out| {
- const i = std.mem.indexOfScalar(u8, trailing, 0) orelse @panic("malformed CompileResult message");
+ const i = std.mem.findScalar(u8, trailing, 0) orelse @panic("malformed CompileResult message");
const file_idx = std.mem.readInt(u32, trailing[i..][1..5], .little);
const sema_count = std.mem.readInt(u32, trailing[i..][5..9], .little);
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 {
defer table_html.deinit(gpa);
for (durations) |test_ns| {
- const test_name_len = std.mem.indexOfScalar(u8, trailing[offset..], 0) orelse @panic("malformed RunTestResult message");
+ const test_name_len = std.mem.findScalar(u8, trailing[offset..], 0) orelse @panic("malformed RunTestResult message");
const test_name = trailing[offset..][0..test_name_len];
offset += test_name_len + 1;
try table_html.print(gpa, "
{f} | ", .{fmtEscapeHtml(test_name)});
diff --git a/lib/compiler/Maker.zig b/lib/compiler/Maker.zig
index b36f6e4e7da2388d368b6d1684c893f362c57a32..1a3a37b6dc008e7c536ab91e505d7559addbc7bb 100644
--- a/lib/compiler/Maker.zig
+++ b/lib/compiler/Maker.zig
@@ -3109,7 +3109,7 @@ pub fn printErrorMessages(
try stderr.setColor(.red);
try writer.writeAll("error:");
try stderr.setColor(.reset);
- if (std.mem.indexOfScalar(u8, msg, '\n') == null) {
+ if (std.mem.findScalar(u8, msg, '\n') == null) {
try writer.print(" {s}\n", .{msg});
} else switch (multiline_errors) {
.indent => {
diff --git a/lib/compiler/Maker/Fetch.zig b/lib/compiler/Maker/Fetch.zig
index 5b5c6f7ff4385ca7cb4d45adcd0233feb24e1bff..13a6cd08c00b72fbf9493ff5acea1631d2542d6a 100644
--- a/lib/compiler/Maker/Fetch.zig
+++ b/lib/compiler/Maker/Fetch.zig
@@ -1164,7 +1164,7 @@ const FileType = enum {
if (cd_header[value_start] != '=') return null;
value_start += 1;
- var value_end = std.mem.indexOfPos(u8, cd_header, value_start, ";") orelse cd_header.len;
+ var value_end = std.mem.findPos(u8, cd_header, value_start, ";") orelse cd_header.len;
if (cd_header[value_end - 1] == '\"') {
value_end -= 1;
}
@@ -1344,7 +1344,7 @@ fn unpackResource(
return f.fail(f.location_tok, try eb.addString("missing 'Content-Type' header"));
// Extract the MIME type, ignoring charset and boundary directives
- const mime_type_end = std.mem.indexOf(u8, content_type, ";") orelse content_type.len;
+ const mime_type_end = std.mem.find(u8, content_type, ";") orelse content_type.len;
const mime_type = content_type[0..mime_type_end];
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
var diagnostics: std.tar.Diagnostics = .{ .allocator = arena };
- std.tar.pipeToFileSystem(io, out_dir, reader, .{
+ std.tar.extract(io, out_dir, reader, .{
.diagnostics = &diagnostics,
.strip_components = 0,
.mode_mode = .ignore,
diff --git a/lib/compiler/Maker/Fetch/git.zig b/lib/compiler/Maker/Fetch/git.zig
index 2e040a81fe68c09eede82fac6ece736efe44cc60..89f5bb6d86f4ef592bb42bbe7584fb2e06863da4 100644
--- a/lib/compiler/Maker/Fetch/git.zig
+++ b/lib/compiler/Maker/Fetch/git.zig
@@ -336,7 +336,7 @@ pub const Repository = struct {
fn next(iterator: *TreeIterator) !?Entry {
if (iterator.pos == iterator.data.len) return null;
- const mode_end = mem.indexOfScalarPos(u8, iterator.data, iterator.pos, ' ') orelse return error.InvalidTree;
+ const mode_end = mem.findScalarPos(u8, iterator.data, iterator.pos, ' ') orelse return error.InvalidTree;
const mode: packed struct {
permission: u9,
unused: u3,
@@ -351,7 +351,7 @@ pub const Repository = struct {
};
iterator.pos = mode_end + 1;
- const name_end = mem.indexOfScalarPos(u8, iterator.data, iterator.pos, 0) orelse return error.InvalidTree;
+ const name_end = mem.findScalarPos(u8, iterator.data, iterator.pos, 0) orelse return error.InvalidTree;
const name = iterator.data[iterator.pos..name_end :0];
iterator.pos = name_end + 1;
@@ -823,7 +823,7 @@ pub const Session = struct {
value: ?[]const u8 = null,
fn parse(data: []const u8) Capability {
- return if (mem.indexOfScalar(u8, data, '=')) |separator_pos|
+ return if (mem.findScalar(u8, data, '=')) |separator_pos|
.{ .key = data[0..separator_pos], .value = data[separator_pos + 1 ..] }
else
.{ .key = data };
@@ -941,17 +941,17 @@ pub const Session = struct {
.flush => return null,
.data => |data| {
const ref_data = Packet.normalizeText(data);
- const oid_sep_pos = mem.indexOfScalar(u8, ref_data, ' ') orelse return error.InvalidRefPacket;
+ const oid_sep_pos = mem.findScalar(u8, ref_data, ' ') orelse return error.InvalidRefPacket;
const oid = Oid.parse(it.format, data[0..oid_sep_pos]) catch return error.InvalidRefPacket;
- const name_sep_pos = mem.indexOfScalarPos(u8, ref_data, oid_sep_pos + 1, ' ') orelse ref_data.len;
+ const name_sep_pos = mem.findScalarPos(u8, ref_data, oid_sep_pos + 1, ' ') orelse ref_data.len;
const name = ref_data[oid_sep_pos + 1 .. name_sep_pos];
var symref_target: ?[]const u8 = null;
var peeled: ?Oid = null;
var last_sep_pos = name_sep_pos;
while (last_sep_pos < ref_data.len) {
- const next_sep_pos = mem.indexOfScalarPos(u8, ref_data, last_sep_pos + 1, ' ') orelse ref_data.len;
+ const next_sep_pos = mem.findScalarPos(u8, ref_data, last_sep_pos + 1, ' ') orelse ref_data.len;
const attribute = ref_data[last_sep_pos + 1 .. next_sep_pos];
if (mem.startsWith(u8, attribute, "symref-target:")) {
symref_target = attribute["symref-target:".len..];
diff --git a/lib/compiler/Maker/Step/Run.zig b/lib/compiler/Maker/Step/Run.zig
index 56fea332016567473fb6a3fc6c385e92b6c28f91..7f74e76954f44e5b965955d5ff5113d07428b6a7 100644
--- a/lib/compiler/Maker/Step/Run.zig
+++ b/lib/compiler/Maker/Step/Run.zig
@@ -555,7 +555,7 @@ const FuzzTestRunner = struct {
const Instance = struct {
child: process.Child,
- message: std.ArrayListAligned(u8, .@"4"),
+ message: std.array_list.Aligned(u8, .@"4"),
broadcast_written: usize,
stderr: std.ArrayList(u8),
stdin_vec: [1][]u8,
@@ -2120,7 +2120,7 @@ fn fmtSnapshotIndicatorLine(buf: []const u8, index: usize) std.fmt.Alt(
}
fn snapshotIndicatorLine(line: FmtIndicatorLine, w: *std.Io.Writer) std.Io.Writer.Error!void {
- const line_begin_index = if (std.mem.lastIndexOfScalar(u8, line.buf[0..line.index], '\n')) |line_begin|
+ const line_begin_index = if (std.mem.findScalarLast(u8, line.buf[0..line.index], '\n')) |line_begin|
line_begin + 1
else
0;
diff --git a/lib/compiler/configurer.zig b/lib/compiler/configurer.zig
index b956ee1716db56768de7e872b7d09345881651b3..e55c37dfcc4db03f4f4fadff8a641a6f5d0c6414 100644
--- a/lib/compiler/configurer.zig
+++ b/lib/compiler/configurer.zig
@@ -83,7 +83,7 @@ pub fn main(init: process.Init.Minimal) !void {
if (mem.cutPrefix(u8, arg, "-D")) |option_contents| {
if (option_contents.len == 0)
fatalWithHint("expected option name after '-D'", .{});
- if (mem.indexOfScalar(u8, option_contents, '=')) |name_end| {
+ if (mem.findScalar(u8, option_contents, '=')) |name_end| {
const option_name = option_contents[0..name_end];
const option_value = option_contents[name_end + 1 ..];
if (try builder.addUserInputOption(option_name, option_value))
diff --git a/lib/compiler/resinator/compile.zig b/lib/compiler/resinator/compile.zig
index 0ac556120885512572c9dde4a8525373849b8c72..10fc7b261c7925e55dee2211ac67139460847618 100644
--- a/lib/compiler/resinator/compile.zig
+++ b/lib/compiler/resinator/compile.zig
@@ -540,7 +540,7 @@ pub const Compiler = struct {
// This currently only checks for NUL bytes, but it should probably also check for
// platform-specific invalid characters like '*', '?', '"', '<', '>', '|' (Windows)
// Related: https://github.com/ziglang/zig/pull/14533#issuecomment-1416888193
- if (std.mem.indexOfScalar(u8, filename_utf8, 0) != null) {
+ if (std.mem.findScalar(u8, filename_utf8, 0) != null) {
return self.addErrorDetailsAndFail(.{
.err = .invalid_filename,
.token = node.filename.getFirstToken(),
@@ -2919,11 +2919,11 @@ fn validateSearchPath(path: []const u8) error{BadPathName}!void {
var component_iterator = std.fs.path.componentIterator(path);
while (component_iterator.next()) |component| {
// https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file
- if (std.mem.indexOfAny(u8, component.name, "\x00<>:\"|?*") != null) return error.BadPathName;
+ if (std.mem.findAny(u8, component.name, "\x00<>:\"|?*") != null) return error.BadPathName;
}
},
else => {
- if (std.mem.indexOfScalar(u8, path, 0) != null) return error.BadPathName;
+ if (std.mem.findScalar(u8, path, 0) != null) return error.BadPathName;
},
}
}
diff --git a/lib/compiler/resinator/cvtres.zig b/lib/compiler/resinator/cvtres.zig
index fb8ce8718907f1b369f4c5126e6d6f3bb554e85a..29d9e14ce8c0cfe4662d6f03cc4c67f8350da173 100644
--- a/lib/compiler/resinator/cvtres.zig
+++ b/lib/compiler/resinator/cvtres.zig
@@ -1056,7 +1056,7 @@ pub const supported_targets = struct {
comptime {
const info = @typeInfo(Arch).@"enum";
for (info.field_names, info.field_values) |field_name, field_value| {
- _ = std.mem.indexOfScalar(Arch, ordered_for_display, @fromBackingInt(@intCast(field_value))) orelse {
+ _ = std.mem.findScalar(Arch, ordered_for_display, @fromBackingInt(@intCast(field_value))) orelse {
@compileError(std.fmt.comptimePrint("'{s}' missing from ordered_for_display", .{field_name}));
};
}
diff --git a/lib/compiler/resinator/errors.zig b/lib/compiler/resinator/errors.zig
index 3fda3d3c52724679a359e370ab8bee677100a45b..cbd5e5c74e31f33086db4ea446c6223ea5b07141 100644
--- a/lib/compiler/resinator/errors.zig
+++ b/lib/compiler/resinator/errors.zig
@@ -506,7 +506,7 @@ pub const ErrorDetails = struct {
// We know that the token slice is a well-formed #pragma code_page(N), so
// we can skip to the first ( and then get the number that follows
const token_slice = self.token.slice(source);
- var number_start = std.mem.indexOfScalar(u8, token_slice, '(').? + 1;
+ var number_start = std.mem.findScalar(u8, token_slice, '(').? + 1;
while (std.ascii.isWhitespace(token_slice[number_start])) {
number_start += 1;
}
diff --git a/lib/compiler/resinator/source_mapping.zig b/lib/compiler/resinator/source_mapping.zig
index 8ae4a70dd0a4afef5c7f346a864693a9dfc799c5..d2f72821c2076d1794e734f741bc25b274595310 100644
--- a/lib/compiler/resinator/source_mapping.zig
+++ b/lib/compiler/resinator/source_mapping.zig
@@ -538,7 +538,7 @@ pub fn handleLineCommand(allocator: Allocator, line_command: []const u8, current
defer allocator.free(filename);
// \x00 bytes in the filename is incompatible with how StringTable works
- if (std.mem.indexOfScalar(u8, filename, '\x00') != null) return error.InvalidLineCommand;
+ if (std.mem.findScalar(u8, filename, '\x00') != null) return error.InvalidLineCommand;
current_mapping.line_num = linenum;
current_mapping.filename.clearRetainingCapacity();
diff --git a/lib/docs/wasm/html_render.zig b/lib/docs/wasm/html_render.zig
index 5bb54f7ad2ba4a7ade1cb71f00b1a6ba037c26ef..cb94a016e44aff8d1b219d2f206a42109f635f17 100644
--- a/lib/docs/wasm/html_render.zig
+++ b/lib/docs/wasm/html_render.zig
@@ -62,7 +62,7 @@ pub fn fileSourceHtml(
var cursor: usize = ast.tokenStart(start_token);
var indent: usize = 0;
- if (std.mem.lastIndexOf(u8, ast.source[0..cursor], "\n")) |newline_index| {
+ if (std.mem.findLast(u8, ast.source[0..cursor], "\n")) |newline_index| {
for (ast.source[newline_index + 1 .. cursor]) |c| {
if (c == ' ') {
indent += 1;
diff --git a/lib/docs/wasm/main.zig b/lib/docs/wasm/main.zig
index 7f8bf047e44235eabdc5350098923ca074e862bd..aba4d2ac4ff5568a9aa072291dc33869af0f1c63 100644
--- a/lib/docs/wasm/main.zig
+++ b/lib/docs/wasm/main.zig
@@ -153,11 +153,11 @@ fn query_exec_fallible(query: []const u8, ignore_case: bool) !void {
continue;
}
// substring, case insensitive match of full decl path
- if (std.mem.indexOf(u8, g.full_path_search_text_lower.items, term) != null) {
+ if (std.mem.find(u8, g.full_path_search_text_lower.items, term) != null) {
points += 2;
continue;
}
- if (std.mem.indexOf(u8, g.doc_search_text.items, term) != null) {
+ if (std.mem.find(u8, g.doc_search_text.items, term) != null) {
points += 1;
continue;
}
@@ -803,7 +803,7 @@ fn unpackInner(tar_bytes: []u8) !void {
if (std.mem.endsWith(u8, tar_file.name, ".zig")) {
log.debug("found file: '{s}'", .{tar_file.name});
const file_name = try gpa.dupe(u8, tar_file.name);
- if (std.mem.indexOfScalar(u8, file_name, '/')) |pkg_name_end| {
+ if (std.mem.findScalar(u8, file_name, '/')) |pkg_name_end| {
const pkg_name = file_name[0..pkg_name_end];
const gop = try Walk.modules.getOrPut(gpa, pkg_name);
const file: Walk.File.Index = @fromBackingInt(@intCast(Walk.files.entries.len));
diff --git a/lib/docs/wasm/markdown/Parser.zig b/lib/docs/wasm/markdown/Parser.zig
index 0b4695983cc7fc7dd89ffbd4273f809fdfe7bba1..3721b11b373b560de6617a4905b56fa106ae6d8e 100644
--- a/lib/docs/wasm/markdown/Parser.zig
+++ b/lib/docs/wasm/markdown/Parser.zig
@@ -159,7 +159,7 @@ const Block = struct {
.heading => null,
.code_block => code_block: {
const trimmed = mem.trimEnd(u8, unindented, " \t");
- if (mem.indexOfNone(u8, trimmed, "`") != null or trimmed.len != b.data.code_block.fence_len) {
+ if (mem.findNone(u8, trimmed, "`") != null or trimmed.len != b.data.code_block.fence_len) {
const effective_indent = @min(indent, b.data.code_block.indent);
break :code_block line[effective_indent..];
} else {
@@ -594,7 +594,7 @@ fn startListItem(unindented_line: []const u8) ?ListItemStart {
};
}
- const number_end = mem.indexOfNone(u8, unindented_line, "0123456789") orelse return null;
+ const number_end = mem.findNone(u8, unindented_line, "0123456789") orelse return null;
const after_number = unindented_line[number_end..];
const marker: Block.Data.ListMarker = if (mem.startsWith(u8, after_number, ". "))
.number_dot
@@ -639,10 +639,10 @@ fn startTableRow(unindented_line: []const u8) ?TableRowStart {
// Ignoring pipes in code spans allows table cells to contain
// code using ||, for example.
const open_start = i;
- i = mem.indexOfNonePos(u8, table_row_content, i, "`") orelse return null;
+ i = mem.findNonePos(u8, table_row_content, i, "`") orelse return null;
const open_len = i - open_start;
- while (mem.indexOfScalarPos(u8, table_row_content, i, '`')) |close_start| {
- i = mem.indexOfNonePos(u8, table_row_content, close_start, "`") orelse return null;
+ while (mem.findScalarPos(u8, table_row_content, i, '`')) |close_start| {
+ i = mem.findNonePos(u8, table_row_content, close_start, "`") orelse return null;
const close_len = i - close_start;
if (close_len == open_len) break;
} else return null;
@@ -794,7 +794,7 @@ fn startCodeBlock(p: *Parser, unindented_line: []const u8) !?CodeBlockStart {
} else "";
// Code block tags may not contain backticks, since that would create
// potential confusion with inline code spans.
- if (fence_len < 3 or mem.indexOfScalar(u8, tag_bytes, '`') != null) return null;
+ if (fence_len < 3 or mem.findScalar(u8, tag_bytes, '`') != null) return null;
return .{
.tag = try p.addString(mem.trim(u8, tag_bytes, " ")),
.fence_len = fence_len,
@@ -1382,12 +1382,12 @@ const InlineParser = struct {
/// parsing.
fn parseCodeSpan(ip: *InlineParser) !void {
const opener_start = ip.pos;
- ip.pos = mem.indexOfNonePos(u8, ip.content, ip.pos, "`") orelse ip.content.len;
+ ip.pos = mem.findNonePos(u8, ip.content, ip.pos, "`") orelse ip.content.len;
const opener_len = ip.pos - opener_start;
const start = ip.pos;
- const end = while (mem.indexOfScalarPos(u8, ip.content, ip.pos, '`')) |closer_start| {
- ip.pos = mem.indexOfNonePos(u8, ip.content, closer_start, "`") orelse ip.content.len;
+ const end = while (mem.findScalarPos(u8, ip.content, ip.pos, '`')) |closer_start| {
+ ip.pos = mem.findNonePos(u8, ip.content, closer_start, "`") orelse ip.content.len;
const closer_len = ip.pos - closer_start;
if (closer_len == opener_len) break closer_start;
@@ -1627,7 +1627,7 @@ fn addScratchStringLine(p: *Parser, line: []const u8) !void {
}
fn isBlank(line: []const u8) bool {
- return mem.indexOfNone(u8, line, " \t") == null;
+ return mem.findNone(u8, line, " \t") == null;
}
fn isPunctuation(c: u8) bool {
diff --git a/lib/fuzzer.zig b/lib/fuzzer.zig
index a6e1a65fbb6fcaba7313cea9503bfd06cc2fd4de..cf051dca8ec935688551a6da922634ae3e8320df 100644
--- a/lib/fuzzer.zig
+++ b/lib/fuzzer.zig
@@ -1085,7 +1085,7 @@ const Fuzzer = struct {
fn removeBest(f: *Fuzzer, i: Input.Index, best_i: u32) void {
const t = &f.tests[f.test_i];
const ref = &t.corpus.items(.ref)[@backingInt(i)];
- const list_i = mem.indexOfScalar(u32, ref.best_i_buf[0..ref.best_i_len], best_i).?;
+ const list_i = mem.findScalar(u32, ref.best_i_buf[0..ref.best_i_len], best_i).?;
ref.best_i_len -= 1;
ref.best_i_buf[list_i] = ref.best_i_buf[ref.best_i_len];
diff --git a/lib/std/Build.zig b/lib/std/Build.zig
index 79b681e7404623d141293d7379d88c94f196f683..eed57a0b15b47b23b54b412c4305f12020b9773c 100644
--- a/lib/std/Build.zig
+++ b/lib/std/Build.zig
@@ -830,7 +830,7 @@ pub fn addTest(b: *Build, options: TestOptions) *Step.Compile {
.kind = if (options.emit_object) .test_obj else .@"test",
.root_module = options.root_module,
.max_rss = options.max_rss,
- .filters = b.dupeStrings(options.filters),
+ .filters = b.graph.dupeStrings(options.filters),
.test_runner = options.test_runner,
.use_llvm = options.use_llvm,
.use_lld = options.use_lld,
@@ -2648,7 +2648,10 @@ pub const LazyPath = union(enum) {
fn dupeInner(lazy_path: LazyPath, arena: Allocator) LazyPath {
return switch (lazy_path) {
- .src_path => |sp| .{ .src_path = .{ .owner = sp.owner, .sub_path = sp.owner.dupePath(sp.sub_path) } },
+ .src_path => |sp| .{ .src_path = .{
+ .owner = sp.owner,
+ .sub_path = sp.owner.graph.dupePath(sp.sub_path),
+ } },
.cwd_relative => |p| .{ .cwd_relative = Graph.dupePathInner(arena, p) },
.relative => |r| .{ .relative = r },
.generated => |gen| .{ .generated = .{
diff --git a/lib/std/Build/Configuration.zig b/lib/std/Build/Configuration.zig
index ccdb74499c7b41ed30b6f8b62953710e207d459b..5743d9800ced11e00ff61ce5a122c6c5bca83b3f 100644
--- a/lib/std/Build/Configuration.zig
+++ b/lib/std/Build/Configuration.zig
@@ -121,7 +121,7 @@ pub const Wip = struct {
}
pub fn hash(_: @This(), adapted_key: []const u8) u64 {
- assert(std.mem.indexOfScalar(u8, adapted_key, 0) == null);
+ assert(std.mem.findScalar(u8, adapted_key, 0) == null);
return std.hash_map.hashString(adapted_key);
}
};
@@ -182,7 +182,7 @@ pub const Wip = struct {
pub fn addString(wip: *Wip, bytes: []const u8) Allocator.Error!String {
const gpa = wip.gpa;
- assert(std.mem.indexOfScalar(u8, bytes, 0) == null);
+ assert(std.mem.findScalar(u8, bytes, 0) == null);
const gop = try wip.string_table.getOrPutContextAdapted(
gpa,
@as([]const u8, bytes),
@@ -439,7 +439,7 @@ pub const Wip = struct {
/// Returned slice expires upon next append to the configuration.
pub fn stringSlice(wip: *const Wip, s: String) [:0]const u8 {
const start_slice = wip.string_bytes.items[@backingInt(s)..];
- return start_slice[0..std.mem.indexOfScalar(u8, start_slice, 0).? :0];
+ return start_slice[0..std.mem.findScalar(u8, start_slice, 0).? :0];
}
};
@@ -1953,7 +1953,7 @@ pub const String = enum(u32) {
pub fn slice(index: String, c: *const Configuration) [:0]const u8 {
const start_slice = c.string_bytes[@backingInt(index)..];
- return start_slice[0..std.mem.indexOfScalar(u8, start_slice, 0).? :0];
+ return start_slice[0..std.mem.findScalar(u8, start_slice, 0).? :0];
}
};
diff --git a/lib/std/Build/Module.zig b/lib/std/Build/Module.zig
index ac5dc3fd9330bee03bcbedce9a6c8d15d6df106c..7189ecd3e40c232b7a833a9d0bbb257835baab7a 100644
--- a/lib/std/Build/Module.zig
+++ b/lib/std/Build/Module.zig
@@ -402,8 +402,8 @@ pub fn addCSourceFiles(m: *Module, options: AddCSourceFilesOptions) void {
const c_source_files = arena.create(CSourceFiles) catch @panic("OOM");
c_source_files.* = .{
.root = options.root orelse b.path(""),
- .files = b.dupeStrings(options.files),
- .flags = b.dupeStrings(options.flags),
+ .files = b.graph.dupeStrings(options.files),
+ .flags = b.graph.dupeStrings(options.flags),
.language = options.language,
};
m.link_objects.append(arena, .{ .c_source_files = c_source_files }) catch @panic("OOM");
diff --git a/lib/std/Build/Step/Compile.zig b/lib/std/Build/Step/Compile.zig
index 90d88f3a20785f3cb892b080212b8cda9afd5f88..0f7cdbc405d74778a28e370c477dcb5b58ca1e8c 100644
--- a/lib/std/Build/Step/Compile.zig
+++ b/lib/std/Build/Step/Compile.zig
@@ -375,7 +375,7 @@ pub fn create(owner: *std.Build, options: Options) *Compile {
const graph = owner.graph;
const arena = graph.arena;
- const name = owner.dupe(options.name);
+ const name = owner.graph.dupeString(options.name);
if (mem.find(u8, name, "/") != null or mem.find(u8, name, "\\") != null) {
panic("invalid name: '{s}'. It looks like a file path, but it is supposed to be the library or application name.", .{name});
}
diff --git a/lib/std/Io/Dispatch.zig b/lib/std/Io/Dispatch.zig
index 1cbbcbaef64a35185ab51a6cc17abc56b4d246af..e8595f3cbdbf24f5acfa642f3cd9ceb698a122c2 100644
--- a/lib/std/Io/Dispatch.zig
+++ b/lib/std/Io/Dispatch.zig
@@ -2782,7 +2782,7 @@ fn realPath(ev: *Evented, fd: c.fd_t, out_buffer: []u8) File.RealPathError!usize
else => |err| return unexpectedErrno(err),
}
}
- const n = std.mem.indexOfScalar(u8, &buffer, 0) orelse buffer.len;
+ const n = std.mem.findScalar(u8, &buffer, 0) orelse buffer.len;
if (n > out_buffer.len) return error.NameTooLong;
@memcpy(out_buffer[0..n], buffer[0..n]);
return n;
@@ -2804,7 +2804,7 @@ fn dirRealPathFile(
while (true) {
if (c.realpath(sub_path_posix, out_buffer.ptr)) |redundant_pointer| {
assert(redundant_pointer == out_buffer.ptr);
- return std.mem.indexOfScalar(u8, out_buffer, 0) orelse out_buffer.len;
+ return std.mem.findScalar(u8, out_buffer, 0) orelse out_buffer.len;
}
const err: c.E = @fromBackingInt(@intCast(c._errno().*));
switch (err) {
@@ -3792,7 +3792,7 @@ fn fileRealPath(userdata: ?*anyopaque, file: File, out_buffer: []u8) File.RealPa
else => |err| return unexpectedErrno(err),
}
}
- const n = std.mem.indexOfScalar(u8, &buffer, 0) orelse buffer.len;
+ const n = std.mem.findScalar(u8, &buffer, 0) orelse buffer.len;
if (n > out_buffer.len) return error.NameTooLong;
@memcpy(out_buffer[0..n], buffer[0..n]);
return n;
diff --git a/lib/std/Io/Threaded.zig b/lib/std/Io/Threaded.zig
index c6473678a20326c606cabf29bd16e27af9ffd843..2c48909a6d169d8ed3ddc5cbc385f176a319864a 100644
--- a/lib/std/Io/Threaded.zig
+++ b/lib/std/Io/Threaded.zig
@@ -6836,7 +6836,7 @@ fn dirRealPathFilePosix(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, o
if (std.c.realpath(sub_path_posix, out_buffer.ptr)) |redundant_pointer| {
syscall.finish();
assert(redundant_pointer == out_buffer.ptr);
- return std.mem.indexOfScalar(u8, out_buffer, 0) orelse out_buffer.len;
+ return std.mem.findScalar(u8, out_buffer, 0) orelse out_buffer.len;
}
const err: posix.E = @fromBackingInt(@intCast(std.c._errno().*));
if (err == .INTR) {
@@ -6980,7 +6980,7 @@ fn realPathPosix(fd: posix.fd_t, out_buffer: []u8) File.RealPathError!usize {
},
}
}
- const n = std.mem.indexOfScalar(u8, &sufficient_buffer, 0) orelse sufficient_buffer.len;
+ const n = std.mem.findScalar(u8, &sufficient_buffer, 0) orelse sufficient_buffer.len;
if (n > out_buffer.len) return error.NameTooLong;
@memcpy(out_buffer[0..n], sufficient_buffer[0..n]);
return n;
@@ -8999,7 +8999,7 @@ fn isCygwinPty(file: File) Io.Cancelable!bool {
// The name we get from NtQueryInformationFile will be prefixed with a '\', e.g. \msys-1888ae32e00d56aa-pty0-to-master
return (std.mem.startsWith(u16, name_wide, &[_]u16{ '\\', 'm', 's', 'y', 's', '-' }) or
std.mem.startsWith(u16, name_wide, &[_]u16{ '\\', 'c', 'y', 'g', 'w', 'i', 'n', '-' })) and
- std.mem.indexOf(u16, name_wide, &[_]u16{ '-', 'p', 't', 'y' }) != null;
+ std.mem.find(u16, name_wide, &[_]u16{ '-', 'p', 't', 'y' }) != null;
}
fn fileSetLength(userdata: ?*anyopaque, file: File, length: u64) File.SetLengthError!void {
@@ -16315,7 +16315,7 @@ fn windowsCreateProcessPathExt(
const is_bat_or_cmd = bat_or_cmd: {
const app_name = app_buf.items[0..app_name_len];
- const ext_start = std.mem.lastIndexOfScalar(u16, app_name, '.') orelse break :bat_or_cmd false;
+ const ext_start = std.mem.findScalarLast(u16, app_name, '.') orelse break :bat_or_cmd false;
const ext = app_name[ext_start..];
const ext_enum = windowsCreateProcessSupportsExtension(ext) orelse break :bat_or_cmd false;
switch (ext_enum) {
@@ -16351,7 +16351,7 @@ fn windowsCreateProcessPathExt(
// it's treated as an unrecoverable error. Otherwise, it'll be
// skipped as normal.
const app_name = app_buf.items[0..app_name_len];
- const ext_start = std.mem.lastIndexOfScalar(u16, app_name, '.') orelse break :unappended err;
+ const ext_start = std.mem.findScalarLast(u16, app_name, '.') orelse break :unappended err;
const ext = app_name[ext_start..];
if (windows.eqlIgnoreCaseWtf16(ext, std.unicode.utf8ToUtf16LeStringLiteral(".EXE"))) {
return error.UnrecoverableInvalidExe;
diff --git a/lib/std/Uri.zig b/lib/std/Uri.zig
index 1dbb8cc043a7fc1354197a89a080af87e2789a48..6c4b1b2346e4cb955cecde24302bb4b15df4df18 100644
--- a/lib/std/Uri.zig
+++ b/lib/std/Uri.zig
@@ -221,16 +221,16 @@ pub fn parseAfterScheme(scheme: []const u8, text: []const u8) ParseError!Uri {
}
if (authority.len > start_of_host and authority[start_of_host] == '[') { // IPv6
- end_of_host = std.mem.lastIndexOf(u8, authority, "]") orelse return error.InvalidFormat;
+ end_of_host = std.mem.findLast(u8, authority, "]") orelse return error.InvalidFormat;
end_of_host += 1;
- if (std.mem.lastIndexOf(u8, authority, ":")) |index| {
+ if (std.mem.findLast(u8, authority, ":")) |index| {
if (index >= end_of_host) { // if not part of the V6 address field
end_of_host = @min(end_of_host, index);
uri.port = std.fmt.parseInt(u16, authority[index + 1 ..], 10) catch return error.InvalidPort;
}
}
- } else if (std.mem.lastIndexOf(u8, authority, ":")) |index| {
+ } else if (std.mem.findLast(u8, authority, ":")) |index| {
if (index >= start_of_host) { // if not part of the userinfo field
end_of_host = @min(end_of_host, index);
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
var aux: Writer = .fixed(aux_buf.*);
if (!base.isEmpty()) {
base.formatPath(&aux) catch return error.NoSpaceLeft;
- aux.end = std.mem.lastIndexOfScalar(u8, aux.buffered(), '/') orelse return remove_dot_segments(new);
+ aux.end = std.mem.findScalarLast(u8, aux.buffered(), '/') orelse return remove_dot_segments(new);
}
aux.print("/{s}", .{new}) catch return error.NoSpaceLeft;
const merged_path = remove_dot_segments(aux.buffered());
diff --git a/lib/std/array_hash_map.zig b/lib/std/array_hash_map.zig
index fd2aa5ebc48b37c335465df7fe6ddf4a0623389b..b688551017f0cb945d67c0fb35d038ec332d7d78 100644
--- a/lib/std/array_hash_map.zig
+++ b/lib/std/array_hash_map.zig
@@ -13,12 +13,12 @@ const hash_map = @This();
///
/// See `AutoContext` for a description of the hash and equal implementations.
pub fn Auto(comptime K: type, comptime V: type) type {
- return ArrayHashMap(K, V, AutoContext(K), !autoEqlIsCheap(K));
+ return Custom(K, V, AutoContext(K), !autoEqlIsCheap(K));
}
/// An `ArrayHashMap` with strings as keys.
pub fn String(comptime V: type) type {
- return ArrayHashMap([]const u8, V, StringContext, true);
+ return Custom([]const u8, V, StringContext, true);
}
pub const StringContext = struct {
@@ -2130,7 +2130,7 @@ test "0 sized key and 0 sized value" {
test "setKey storehash true" {
const gpa = std.testing.allocator;
- var map: ArrayHashMap(i32, i32, AutoContext(i32), true) = .empty;
+ var map: Custom(i32, i32, AutoContext(i32), true) = .empty;
defer map.deinit(gpa);
try map.put(gpa, 12, 34);
@@ -2146,7 +2146,7 @@ test "setKey storehash true" {
test "setKey storehash false" {
const gpa = std.testing.allocator;
- var map: ArrayHashMap(i32, i32, AutoContext(i32), false) = .empty;
+ var map: Custom(i32, i32, AutoContext(i32), false) = .empty;
defer map.deinit(gpa);
try map.put(gpa, 12, 34);
@@ -2162,7 +2162,7 @@ test "setKey storehash false" {
test "setKey storehash false with index" {
const gpa = std.testing.allocator;
- const T = ArrayHashMap(usize, usize, AutoContext(usize), false);
+ const T = Custom(usize, usize, AutoContext(usize), false);
var map: T = .empty;
defer map.deinit(gpa);
@@ -2180,9 +2180,9 @@ test "setKey storehash false with index" {
test "setKey storehash true with index" {
const gpa = std.testing.allocator;
- const T = ArrayHashMap(usize, usize, AutoContext(usize), false);
+ const T = Custom(usize, usize, AutoContext(usize), false);
- var map: ArrayHashMap(usize, usize, AutoContext(usize), true) = .empty;
+ var map: Custom(usize, usize, AutoContext(usize), true) = .empty;
defer map.deinit(gpa);
for (0..T.linear_scan_max + 1) |i| try map.put(gpa, i, i);
diff --git a/lib/std/crypto/Certificate.zig b/lib/std/crypto/Certificate.zig
index f0d18e58a130cd18d0eb8c00dba3b6f32903c802..3bf35280d7a250a3bc029e8797da5da1ac97e92d 100644
--- a/lib/std/crypto/Certificate.zig
+++ b/lib/std/crypto/Certificate.zig
@@ -1148,9 +1148,9 @@ pub const rsa = struct {
}
var m_p_buf: [8 + Hash.digest_length + Hash.digest_length]u8 = undefined;
var m_p = m_p_buf[0 .. 8 + Hash.digest_length + sLen];
- std.mem.copyForwards(u8, m_p, @as(*const [8]u8, &@splat(0)));
- std.mem.copyForwards(u8, m_p[8..], &mHash);
- std.mem.copyForwards(u8, m_p[(8 + Hash.digest_length)..], salt);
+ @memmove(m_p, @as(*const [8]u8, &@splat(0)));
+ @memmove(m_p[8..], &mHash);
+ @memmove(m_p[(8 + Hash.digest_length)..], salt);
// 13. Let H' = Hash(M'), an octet string of length hLen.
var h_p: [Hash.digest_length]u8 = undefined;
diff --git a/lib/std/fs/path.zig b/lib/std/fs/path.zig
index 7eede9c715f6121e9bff5151cb40fd59615f592d..ffba84b9e3f80c70fa9de109525bf8a3f3262ed2 100644
--- a/lib/std/fs/path.zig
+++ b/lib/std/fs/path.zig
@@ -1830,7 +1830,7 @@ fn testRelativeWindows(from: []const u8, to: []const u8, expected_output: []cons
/// pointer address range of `path`, even if it is length zero.
pub fn extension(path: []const u8) []const u8 {
const filename = basename(path);
- const index = mem.lastIndexOfScalar(u8, filename, '.') orelse return path[path.len..];
+ const index = mem.findScalarLast(u8, filename, '.') orelse return path[path.len..];
if (index == 0) return path[path.len..];
return filename[index..];
}
@@ -1887,7 +1887,7 @@ test extension {
/// - "hello/world/lib" ⇒ "lib"
pub fn stem(path: []const u8) []const u8 {
const filename = basename(path);
- const index = mem.lastIndexOfScalar(u8, filename, '.') orelse return filename[0..];
+ const index = mem.findScalarLast(u8, filename, '.') orelse return filename[0..];
if (index == 0) return path;
return filename[0..index];
}
diff --git a/lib/std/heap/SafeAllocator.zig b/lib/std/heap/SafeAllocator.zig
index 41199df8aa39d526938dc72a2ceccd80168c3dc0..91f65184241713f66a39953092d889cd2bed4b84 100644
--- a/lib/std/heap/SafeAllocator.zig
+++ b/lib/std/heap/SafeAllocator.zig
@@ -1519,7 +1519,7 @@ const FuzzSingleThreadedAllocator = struct {
@disableInstrumentation();
const allocs_slice = f.allocs.slice();
- const i = mem.indexOfScalar([*]u8, allocs_slice.items(.ptr), memory.ptr) orelse panic(
+ const i = mem.findScalar([*]u8, allocs_slice.items(.ptr), memory.ptr) orelse panic(
"invalid SafeAllocator free of {f}",
.{FormatMemory{ .memory = memory, .alignment = alignment }},
);
diff --git a/lib/std/http/Server.zig b/lib/std/http/Server.zig
index 6523fa672f005664296726a858d40b3935b5561f..c505605c03406e3ef760fabe031175358a207cd5 100644
--- a/lib/std/http/Server.zig
+++ b/lib/std/http/Server.zig
@@ -102,7 +102,7 @@ pub const Request = struct {
const method = std.meta.stringToEnum(http.Method, first_line[0..method_end]) orelse
return error.UnknownHttpMethod;
- const version_start = mem.lastIndexOfScalar(u8, first_line, ' ') orelse
+ const version_start = mem.findScalarLast(u8, first_line, ' ') orelse
return error.HttpHeadersInvalid;
if (version_start == method_end) return error.HttpHeadersInvalid;
diff --git a/lib/std/mem.zig b/lib/std/mem.zig
index 2d0d5f7d8bbb5653dbdaf55ee95c2cf85fa47b5e..55b9019c4f4d95cfce0f271de52d12a856f9aea8 100644
--- a/lib/std/mem.zig
+++ b/lib/std/mem.zig
@@ -1528,7 +1528,7 @@ pub fn findLast(comptime T: type, haystack: []const T, needle: []const T) ?usize
if (needle.len == 0) return haystack.len;
if (!std.meta.hasUniqueRepresentation(T) or haystack.len < 52 or needle.len <= 4)
- return lastIndexOfLinear(T, haystack, needle);
+ return findLastLinear(T, haystack, needle);
const haystack_bytes = sliceAsBytes(haystack);
const needle_bytes = sliceAsBytes(needle);
@@ -1583,26 +1583,26 @@ pub fn findPos(comptime T: type, haystack: []const T, start_index: usize, needle
test find {
try testing.expect(find(u8, "one two three four five six seven eight nine ten eleven", "three four").? == 8);
- try testing.expect(lastIndexOf(u8, "one two three four five six seven eight nine ten eleven", "three four").? == 8);
+ try testing.expect(findLast(u8, "one two three four five six seven eight nine ten eleven", "three four").? == 8);
try testing.expect(find(u8, "one two three four five six seven eight nine ten eleven", "two two") == null);
- try testing.expect(lastIndexOf(u8, "one two three four five six seven eight nine ten eleven", "two two") == null);
+ try testing.expect(findLast(u8, "one two three four five six seven eight nine ten eleven", "two two") == null);
try testing.expect(find(u8, "one two three four five six seven eight nine ten", "").? == 0);
- try testing.expect(lastIndexOf(u8, "one two three four five six seven eight nine ten", "").? == 48);
+ try testing.expect(findLast(u8, "one two three four five six seven eight nine ten", "").? == 48);
try testing.expect(find(u8, "one two three four", "four").? == 14);
- try testing.expect(lastIndexOf(u8, "one two three two four", "two").? == 14);
+ try testing.expect(findLast(u8, "one two three two four", "two").? == 14);
try testing.expect(find(u8, "one two three four", "gour") == null);
- try testing.expect(lastIndexOf(u8, "one two three four", "gour") == null);
+ try testing.expect(findLast(u8, "one two three four", "gour") == null);
try testing.expect(find(u8, "foo", "foo").? == 0);
- try testing.expect(lastIndexOf(u8, "foo", "foo").? == 0);
+ try testing.expect(findLast(u8, "foo", "foo").? == 0);
try testing.expect(find(u8, "foo", "fool") == null);
- try testing.expect(lastIndexOf(u8, "foo", "lfoo") == null);
- try testing.expect(lastIndexOf(u8, "foo", "fool") == null);
+ try testing.expect(findLast(u8, "foo", "lfoo") == null);
+ try testing.expect(findLast(u8, "foo", "fool") == null);
try testing.expect(find(u8, "foo foo", "foo").? == 0);
- try testing.expect(lastIndexOf(u8, "foo foo", "foo").? == 4);
- try testing.expect(lastIndexOfAny(u8, "boo, cat", "abo").? == 6);
+ try testing.expect(findLast(u8, "foo foo", "foo").? == 4);
+ try testing.expect(findLastAny(u8, "boo, cat", "abo").? == 6);
try testing.expect(findScalarLast(u8, "boo", 'o').? == 2);
}
@@ -1624,13 +1624,13 @@ test "find multibyte" {
// make haystack and needle long enough to trigger Boyer-Moore-Horspool algorithm
const haystack = [_]u16{ 0xbbaa, 0xccbb, 0xddcc, 0xeedd, 0xffee, 0x00ff } ++ @as([100]u16, @splat(0));
const needle = [_]u16{ 0xbbaa, 0xccbb, 0xddcc, 0xeedd, 0xffee };
- try testing.expectEqual(lastIndexOf(u16, &haystack, &needle), 0);
+ try testing.expectEqual(findLast(u16, &haystack, &needle), 0);
// check for misaligned false positives (little and big endian)
const needleLE = [_]u16{ 0xbbbb, 0xcccc, 0xdddd, 0xeeee, 0xffff };
- try testing.expectEqual(lastIndexOf(u16, &haystack, &needleLE), null);
+ try testing.expectEqual(findLast(u16, &haystack, &needleLE), null);
const needleBE = [_]u16{ 0xaacc, 0xbbdd, 0xccee, 0xddff, 0xee00 };
- try testing.expectEqual(lastIndexOf(u16, &haystack, &needleBE), null);
+ try testing.expectEqual(findLast(u16, &haystack, &needleBE), null);
}
}
@@ -3485,8 +3485,8 @@ pub fn SplitBackwardsIterator(comptime T: type, comptime delimiter_type: Delimit
pub fn next(self: *Self) ?[]const T {
const end = self.index orelse return null;
const start = if (switch (delimiter_type) {
- .sequence => lastIndexOf(T, self.buffer[0..end], self.delimiter),
- .any => lastIndexOfAny(T, self.buffer[0..end], self.delimiter),
+ .sequence => findLast(T, self.buffer[0..end], self.delimiter),
+ .any => findLastAny(T, self.buffer[0..end], self.delimiter),
.scalar => findScalarLast(T, self.buffer[0..end], self.delimiter),
}) |delim_start| blk: {
self.index = delim_start;
diff --git a/lib/std/os/linux/IoUring/test.zig b/lib/std/os/linux/IoUring/test.zig
index 891ce5a397f61e2b6c655192d714e35d21f7e32c..070bd4245f12cdcc48723e5db51ac72d5d74f2bf 100644
--- a/lib/std/os/linux/IoUring/test.zig
+++ b/lib/std/os/linux/IoUring/test.zig
@@ -2699,7 +2699,7 @@ inline fn skipKernelLessThan(required: std.SemanticVersion) !void {
const release = mem.sliceTo(&uts.release, 0);
// Strips potential extra, as kernel version might not be semver compliant, example "6.8.9-300.fc40.x86_64"
- const extra_index = std.mem.indexOfAny(u8, release, "-+");
+ const extra_index = std.mem.findAny(u8, release, "-+");
const stripped = release[0..(extra_index orelse release.len)];
// Make sure the input don't rely on the extra we just stripped
try testing.expect(required.pre == null and required.build == null);
diff --git a/lib/std/tar/Writer.zig b/lib/std/tar/Writer.zig
index 85941c967fcd831bc725480d715ce9d946f363a1..d43c8962d8205c35648855dbc1e6cc4bbd893edb 100644
--- a/lib/std/tar/Writer.zig
+++ b/lib/std/tar/Writer.zig
@@ -312,7 +312,7 @@ pub const Header = extern struct {
// add as much to prefix as you can, must split at /
const prefix_remaining = max_prefix - prefix_pos;
- if (std.mem.lastIndexOf(u8, sub_path[0..@min(prefix_remaining, sub_path.len)], &.{'/'})) |sep_pos| {
+ if (std.mem.findLast(u8, sub_path[0..@min(prefix_remaining, sub_path.len)], &.{'/'})) |sep_pos| {
@memcpy(w.prefix[prefix_pos..][0..sep_pos], sub_path[0..sep_pos]);
if ((sub_path.len - sep_pos - 1) > max_name) return error.NameTooLong;
@memcpy(w.name[0..][0 .. sub_path.len - sep_pos - 1], sub_path[sep_pos + 1 ..]);
diff --git a/lib/std/tar/test.zig b/lib/std/tar/test.zig
index e01fd4b884dd4b0cff328238b60288bc2a535d87..fa66d51cedb7730012d1b432c90f8d98928610c0 100644
--- a/lib/std/tar/test.zig
+++ b/lib/std/tar/test.zig
@@ -474,14 +474,14 @@ test "should not overwrite existing file" {
defer root.cleanup();
try testing.expectError(
error.PathAlreadyExists,
- tar.pipeToFileSystem(io, root.dir, &r, .{ .mode_mode = .ignore, .strip_components = 1 }),
+ tar.extract(io, root.dir, &r, .{ .mode_mode = .ignore, .strip_components = 1 }),
);
// Unpack with strip_components = 0 should pass
r = .fixed(data);
var root2 = std.testing.tmpDir(.{});
defer root2.cleanup();
- try tar.pipeToFileSystem(io, root2.dir, &r, .{ .mode_mode = .ignore, .strip_components = 0 });
+ try tar.extract(io, root2.dir, &r, .{ .mode_mode = .ignore, .strip_components = 0 });
}
test "case sensitivity" {
@@ -501,7 +501,7 @@ test "case sensitivity" {
var root = std.testing.tmpDir(.{});
defer root.cleanup();
- tar.pipeToFileSystem(io, root.dir, &r, .{ .mode_mode = .ignore, .strip_components = 1 }) catch |err| {
+ tar.extract(io, root.dir, &r, .{ .mode_mode = .ignore, .strip_components = 1 }) catch |err| {
// on case insensitive fs we fail on overwrite existing file
try testing.expectEqual(error.PathAlreadyExists, err);
return;
diff --git a/lib/std/testing.zig b/lib/std/testing.zig
index 46c7fe938b22300c23dcedc3570cb329090d3d3a..eebf3a5195c0d2407c7c51d3b67ef794011f6736 100644
--- a/lib/std/testing.zig
+++ b/lib/std/testing.zig
@@ -999,7 +999,7 @@ test "expectEqualDeep composite type" {
}
fn printIndicatorLine(source: []const u8, indicator_index: usize) void {
- const line_begin_index = if (std.mem.lastIndexOfScalar(u8, source[0..indicator_index], '\n')) |line_begin|
+ const line_begin_index = if (std.mem.findScalarLast(u8, source[0..indicator_index], '\n')) |line_begin|
line_begin + 1
else
0;
diff --git a/lib/std/testing/Smith.zig b/lib/std/testing/Smith.zig
index a60a9802391078fe6ca400fb4409216bd73ff345..39da2910c5657b62ac6bac5103bca1e286a63cf7 100644
--- a/lib/std/testing/Smith.zig
+++ b/lib/std/testing/Smith.zig
@@ -52,7 +52,7 @@ pub inline fn baselineWeights(T: type) []const Weight {
.bool, .int, .float => i: {
// Reject types that don't have a fixed bitsize (esp. usize)
// since they are not gauraunteed to fit in a u64 across targets.
- if (std.mem.indexOfScalar(type, &.{
+ if (std.mem.findScalar(type, &.{
isize, usize,
c_char, c_longdouble,
c_short, c_ushort,
diff --git a/lib/std/zig.zig b/lib/std/zig.zig
index 4a5232f27b506faa9205badfb2ef194e96583e64..332e0114b02c3cf9747c0d3bba2021eb1b15befd 100644
--- a/lib/std/zig.zig
+++ b/lib/std/zig.zig
@@ -1560,7 +1560,7 @@ pub fn resolvePath(
// Heuristic for a fast path: if no component is absolute and ".." never appears, we just need to resolve `paths`.
for (paths) |p| {
if (Dir.path.isAbsolute(p)) break; // absolute path
- if (mem.indexOf(u8, p, "..") != null) break; // may contain up-dir
+ if (mem.find(u8, p, "..") != null) break; // may contain up-dir
} else {
// no absolute path, no "..".
const res = try Dir.path.resolve(gpa, paths);
diff --git a/lib/std/zig/Ast/Render.zig b/lib/std/zig/Ast/Render.zig
index 53d9027d1351ebcd4a5658f6d3702bfe22cc95ca..ddbaea460f5f37dd9885bf00db51c1d62d827ff2 100644
--- a/lib/std/zig/Ast/Render.zig
+++ b/lib/std/zig/Ast/Render.zig
@@ -941,20 +941,20 @@ fn renderExpressionFixup(r: *Render, node: Ast.Node.Index, space: Space) Error!v
}
fn drainNoNewline(w: *Writer, data: []const []const u8, splat: usize) Writer.Error!usize {
- if (std.mem.indexOfScalar(u8, w.buffered(), '\n') != null) {
+ if (std.mem.findScalar(u8, w.buffered(), '\n') != null) {
return error.WriteFailed;
}
var n: usize = 0;
for (data[0 .. data.len - 1]) |v| {
- if (std.mem.indexOfScalar(u8, v, '\n') != null) {
+ if (std.mem.findScalar(u8, v, '\n') != null) {
return error.WriteFailed;
}
n += v.len;
}
const pattern = data[data.len - 1];
- if (splat != 0 and std.mem.indexOfScalar(u8, pattern, '\n') != null) {
+ if (splat != 0 and std.mem.findScalar(u8, pattern, '\n') != null) {
return error.WriteFailed;
}
n += pattern.len * splat;
@@ -990,7 +990,7 @@ fn rendersMultiline(r: *const Render, node: Ast.Node.Index) error{OutOfMemory}!b
error.WriteFailed => return true,
};
if (sub_ais.disabled_offset != null) return true;
- if (std.mem.indexOfScalar(u8, no_nl_w.buffered(), '\n') != null) {
+ if (std.mem.findScalar(u8, no_nl_w.buffered(), '\n') != null) {
return true;
}
@@ -2993,7 +2993,7 @@ fn hasMultilineString(tree: Ast, start_token: Ast.TokenIndex, end_token: Ast.Tok
/// Returns true if there exists a doc comment between the start
/// of token `start_token` and the start of token `end_token`.
fn hasDocComment(tree: Ast, start_token: Ast.TokenIndex, end_token: Ast.TokenIndex) bool {
- return std.mem.indexOfScalar(
+ return std.mem.findScalar(
Token.Tag,
tree.tokens.items(.tag)[start_token..end_token],
.doc_comment,
diff --git a/lib/std/zig/llvm/Builder.zig b/lib/std/zig/llvm/Builder.zig
index 9016796a73b0f98f2ded17ef132ea9b4466140ca..890ead68aa27a8c0f7f6cd75b97c822f1e8e77c0 100644
--- a/lib/std/zig/llvm/Builder.zig
+++ b/lib/std/zig/llvm/Builder.zig
@@ -9919,7 +9919,7 @@ pub fn attrs(self: *Builder, attributes: []Attribute.Index) Allocator.Error!Attr
pub fn fnAttrs(self: *Builder, fn_attributes: []const Attributes) Allocator.Error!FunctionAttributes {
try self.function_attributes_set.ensureUnusedCapacity(self.gpa, 1);
const function_attributes: FunctionAttributes = @fromBackingInt(try self.attrGeneric(@ptrCast(
- fn_attributes[0..if (std.mem.lastIndexOfNone(Attributes, fn_attributes, &.{.none})) |last|
+ fn_attributes[0..if (std.mem.findLastNone(Attributes, fn_attributes, &.{.none})) |last|
last + 1
else
0],
diff --git a/lib/std/zip.zig b/lib/std/zip.zig
index a42a9f395c694c7df04d78e7ca63baafae3b6cfd..1434702ffbf62f3db7fd1b0c133d1af501365133 100644
--- a/lib/std/zip.zig
+++ b/lib/std/zip.zig
@@ -109,7 +109,7 @@ pub const EndRecord = extern struct {
/// TODO audit this logic
pub fn findBuffer(buffer: []const u8) FindBufferError!EndRecord {
- const pos = std.mem.lastIndexOf(u8, buffer, &end_record_sig) orelse return error.ZipNoEndRecord;
+ const pos = std.mem.findLast(u8, buffer, &end_record_sig) orelse return error.ZipNoEndRecord;
if (pos + @sizeOf(EndRecord) > buffer.len) return error.EndOfStream;
const record_ptr: *EndRecord = @ptrCast(buffer[pos..][0..@sizeOf(EndRecord)]);
var record = record_ptr.*;
diff --git a/src/Air.zig b/src/Air.zig
index fbaa370132a6044191d71a7b68d79915584fd979..ad4526f0760417f5b90819864a73c62e7f6c00a3 100644
--- a/src/Air.zig
+++ b/src/Air.zig
@@ -1907,7 +1907,7 @@ pub const NullTerminatedString = enum(u32) {
pub fn toSlice(nts: NullTerminatedString, air: Air) [:0]const u8 {
if (nts == .none) return "";
const bytes = std.mem.sliceAsBytes(air.extra.items[@backingInt(nts)..]);
- return bytes[0..std.mem.indexOfScalar(u8, bytes, 0).? :0];
+ return bytes[0..std.mem.findScalar(u8, bytes, 0).? :0];
}
};
diff --git a/src/IncrementalDebugServer.zig b/src/IncrementalDebugServer.zig
index 20c1af1969ad117ee63acd6428f1ee0c8490f6e6..cbbe07ba3d212b5e485159e089d90c2d6f9a75ef 100644
--- a/src/IncrementalDebugServer.zig
+++ b/src/IncrementalDebugServer.zig
@@ -130,7 +130,7 @@ fn serveStream(
try stream_writer.writeAll("zig> ");
const untrimmed = try stream_reader.takeSentinel('\n');
const cmd_and_arg = std.mem.trim(u8, untrimmed, " \t\r\n");
- const cmd: []const u8, const arg: []const u8 = if (std.mem.indexOfScalar(u8, cmd_and_arg, ' ')) |i|
+ const cmd: []const u8, const arg: []const u8 = if (std.mem.findScalar(u8, cmd_and_arg, ' ')) |i|
.{ cmd_and_arg[0..i], cmd_and_arg[i + 1 ..] }
else
.{ cmd_and_arg, "" };
@@ -244,7 +244,7 @@ fn handleCommand(zcu: *Zcu, w: *Io.Writer, cmd_str: []const u8, arg_str: []const
const ty: Type = .fromInterned(type_ip_index);
const ty_name = ty.containerTypeName(ip).toSlice(ip);
const success = switch (@as(u2, @intFromBool(anchor_start)) << 1 | @intFromBool(anchor_end)) {
- 0b00 => std.mem.indexOf(u8, ty_name, query) != null,
+ 0b00 => std.mem.find(u8, ty_name, query) != null,
0b01 => std.mem.endsWith(u8, ty_name, query),
0b10 => std.mem.startsWith(u8, ty_name, query),
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
const nav = ip.getNav(nav_index);
const nav_fqn = nav.fqn.toSlice(ip);
const success = switch (@as(u2, @intFromBool(anchor_start)) << 1 | @intFromBool(anchor_end)) {
- 0b00 => std.mem.indexOf(u8, nav_fqn, query) != null,
+ 0b00 => std.mem.find(u8, nav_fqn, query) != null,
0b01 => std.mem.endsWith(u8, nav_fqn, query),
0b10 => std.mem.startsWith(u8, nav_fqn, query),
0b11 => std.mem.eql(u8, nav_fqn, query),
@@ -378,7 +378,7 @@ fn parseIndex(str: []const u8) ?u32 {
return std.fmt.parseInt(u32, str, 10) catch null;
}
fn parseAnalUnit(str: []const u8) ?AnalUnit {
- const split_idx = std.mem.indexOfScalar(u8, str, ' ') orelse return null;
+ const split_idx = std.mem.findScalar(u8, str, ' ') orelse return null;
const kind = str[0..split_idx];
const idx_str = str[split_idx + 1 ..];
if (std.mem.eql(u8, kind, "comptime")) {
diff --git a/src/InternPool.zig b/src/InternPool.zig
index 8502055c372f2fb915be32133ee6a8be60916e4b..a5c3bdd044920a3fa745249467879385ed20fbec 100644
--- a/src/InternPool.zig
+++ b/src/InternPool.zig
@@ -1737,7 +1737,7 @@ pub const String = enum(u32) {
}
pub fn toNullTerminatedString(string: String, len: u64, ip: *const InternPool) NullTerminatedString {
- assert(std.mem.indexOfScalar(u8, string.toSlice(len, ip), 0) == null);
+ assert(std.mem.findScalar(u8, string.toSlice(len, ip), 0) == null);
assert(string.at(len, ip) == 0);
return @fromBackingInt(@intCast(@backingInt(string)));
}
@@ -1864,7 +1864,7 @@ pub const NullTerminatedString = enum(u32) {
pub fn toUnsigned(string: NullTerminatedString, ip: *const InternPool) ?u32 {
const slice = string.toSlice(ip);
if (slice.len > 1 and slice[0] == '0') return null;
- if (std.mem.indexOfScalar(u8, slice, '_')) |_| return null;
+ if (std.mem.findScalar(u8, slice, '_')) |_| return null;
return std.fmt.parseUnsigned(u32, slice, 10) catch null;
}
@@ -11428,7 +11428,7 @@ pub fn getOrPutTrailingString(
.tid = tid,
.index = strings.mutate.len - 1,
}).wrap(ip))));
- const has_embedded_null = std.mem.indexOfScalar(u8, key, 0) != null;
+ const has_embedded_null = std.mem.findScalar(u8, key, 0) != null;
switch (embedded_nulls) {
.no_embedded_nulls => assert(!has_embedded_null),
.maybe_embedded_nulls => if (has_embedded_null) {
diff --git a/src/Sema.zig b/src/Sema.zig
index b2bdfc6abf88324c01e74d78dae9473c5143ac8e..c7d40ffa095a3416a65806bba49d84f6bbbc8da7 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -34856,7 +34856,7 @@ pub fn resolveNavPtrModifiers(
const linksection_body = zir_decl.linksection_body orelse break :ls .none;
const linksection_ref = try sema.resolveInlineBody(block, linksection_body, decl_inst);
const bytes = try sema.toConstString(block, section_src, linksection_ref, .{ .simple = .@"linksection" });
- if (std.mem.indexOfScalar(u8, bytes, 0) != null) {
+ if (std.mem.findScalar(u8, bytes, 0) != null) {
return sema.fail(block, section_src, "linksection cannot contain null bytes", .{});
} else if (bytes.len == 0) {
return sema.fail(block, section_src, "linksection cannot be empty", .{});
diff --git a/src/Value.zig b/src/Value.zig
index f6905eb4b55d11df4c1610c9c8e41475cd4fe522..a5b685c7913117befb984dfb85dd5d7f081e5721 100644
--- a/src/Value.zig
+++ b/src/Value.zig
@@ -954,7 +954,7 @@ pub fn anyScalarIsZero(val: Value, zcu: *Zcu) bool {
.bytes => |str| {
const len = Type.fromInterned(agg.ty).vectorLen(zcu);
const slice = str.toSlice(len, &zcu.intern_pool);
- return std.mem.indexOfScalar(u8, slice, 0) != null;
+ return std.mem.findScalar(u8, slice, 0) != null;
},
.elems => |elems| {
for (elems) |elem| {
diff --git a/src/Zcu.zig b/src/Zcu.zig
index 92659d3253b60fb26eddac3eadf3ce9ec6ba1499..5f64440990c95be60453ee38c1dde3d2850a058f 100644
--- a/src/Zcu.zig
+++ b/src/Zcu.zig
@@ -652,7 +652,7 @@ pub const StdLangDecl = enum {
return switch (decl) {
inline else => |tag| {
const name = @tagName(tag);
- const split = (comptime std.mem.lastIndexOfScalar(u8, name, '.')) orelse return .{ .direct = name };
+ const split = (comptime std.mem.findScalarLast(u8, name, '.')) orelse return .{ .direct = name };
const parent = @field(StdLangDecl, name[0..split]);
comptime assert(@backingInt(parent) < @backingInt(tag)); // dependencies ordered correctly
return .{ .nested = .{ parent, name[split + 1 ..] } };
@@ -4299,7 +4299,7 @@ fn resolveReferencesInner(zcu: *Zcu) Allocator.Error!std.array_hash_map.Auto(Ana
const fqn_slice = nav.fqn.toSlice(ip);
if (comp.test_filters.len > 0) {
for (comp.test_filters) |test_filter| {
- if (std.mem.indexOf(u8, fqn_slice, test_filter) != null) break;
+ if (std.mem.find(u8, fqn_slice, test_filter) != null) break;
} else break :a false;
}
break :a true;
diff --git a/src/Zcu/PerThread.zig b/src/Zcu/PerThread.zig
index bf72a73851b39910c3d43250a286efa98f780b20..64240f77c1c721bfcf90be0def4bb92aa7b07e99 100644
--- a/src/Zcu/PerThread.zig
+++ b/src/Zcu/PerThread.zig
@@ -3176,7 +3176,7 @@ const ScanDeclIter = struct {
if (is_named and comp.test_filters.len > 0) {
const fqn_slice = fqn.toSlice(ip);
for (comp.test_filters) |test_filter| {
- if (std.mem.indexOf(u8, fqn_slice, test_filter) != null) break;
+ if (std.mem.find(u8, fqn_slice, test_filter) != null) break;
} else break :a false;
}
try zcu.test_functions.put(gpa, nav, {});
diff --git a/src/codegen/aarch64/Assemble.zig b/src/codegen/aarch64/Assemble.zig
index 2875f6fc960e211f684d37815ba86de291fd8453..2d5cc913270f0259caa726e4073b34e1992fef8f 100644
--- a/src/codegen/aarch64/Assemble.zig
+++ b/src/codegen/aarch64/Assemble.zig
@@ -163,7 +163,7 @@ const matchers = matchers: {
arg.* = zonCast(param_type.?, instruction.encode[encode_index], symbols);
return @call(.auto, encode, args);
} else if (pattern_token[0] == '<') {
- const symbol_name = comptime pattern_token[1 .. std.mem.indexOfScalarPos(u8, pattern_token, 1, '|') orelse
+ const symbol_name = comptime pattern_token[1 .. std.mem.findScalarPos(u8, pattern_token, 1, '|') orelse
pattern_token.len - 1];
const symbol = @field(Symbol, symbol_name);
const symbol_ptr = &@field(symbols, symbol_name);
diff --git a/src/codegen/aarch64/Select.zig b/src/codegen/aarch64/Select.zig
index 1050b8fb0eb1425205f04b7440640ec55d6cf69a..520bad02743a1a0537226e7f40a6595046a3a42b 100644
--- a/src/codegen/aarch64/Select.zig
+++ b/src/codegen/aarch64/Select.zig
@@ -2856,7 +2856,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory,
const remaining_source = std.mem.span(as.source);
return isel.fail("unable to assemble: '{s}'", .{std.mem.trim(
u8,
- as.source[0 .. std.mem.indexOfScalar(u8, remaining_source, '\n') orelse remaining_source.len],
+ as.source[0 .. std.mem.findScalar(u8, remaining_source, '\n') orelse remaining_source.len],
&std.ascii.whitespace,
)});
},
diff --git a/src/codegen/c.zig b/src/codegen/c.zig
index 5ab86a9a5fad9e1a4391053bd5e1af970de1feeb..f2c8431dcab682067b18a9c785e1ac2edda4ade5 100644
--- a/src/codegen/c.zig
+++ b/src/codegen/c.zig
@@ -5013,7 +5013,7 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {
while (it.next()) |input| {
const constraint = input.constraint;
- if (constraint.len < 1 or mem.indexOfScalar(u8, "=+&%", constraint[0]) != null or
+ if (constraint.len < 1 or mem.findScalar(u8, "=+&%", constraint[0]) != null or
(constraint[0] == '{' and constraint[constraint.len - 1] != '}'))
{
return f.fail("CBE: constraint not supported: '{s}'", .{constraint});
@@ -5077,7 +5077,7 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {
}
const desc = mem.sliceTo(asm_source[src_i..], ']');
- if (mem.indexOfScalar(u8, desc, ':')) |colon| {
+ if (mem.findScalar(u8, desc, ':')) |colon| {
const name = desc[0..colon];
const modifier = desc[colon + 1 ..];
diff --git a/src/codegen/riscv64/CodeGen.zig b/src/codegen/riscv64/CodeGen.zig
index aed925be2953ddfb56581b9bb5eef521e8b78507..1a6ae84190bf394992f5e30b305de583be9b5829 100644
--- a/src/codegen/riscv64/CodeGen.zig
+++ b/src/codegen/riscv64/CodeGen.zig
@@ -6235,8 +6235,8 @@ fn airAsm(func: *Func, inst: Air.Inst.Index) !void {
next_op: for (&ops) |*op| {
const op_str = while (!last_op) {
const full_str = op_it.next() orelse break :next_op;
- const code_str = if (mem.indexOfScalar(u8, full_str, '#') orelse
- mem.indexOf(u8, full_str, "//")) |comment|
+ const code_str = if (mem.findScalar(u8, full_str, '#') orelse
+ mem.find(u8, full_str, "//")) |comment|
code: {
last_op = true;
break :code full_str[0..comment];
@@ -6250,7 +6250,7 @@ fn airAsm(func: *Func, inst: Air.Inst.Index) !void {
} else if (std.fmt.parseInt(i12, op_str, 10)) |int| {
op.* = .{ .imm = Immediate.s(int) };
} else |_| if (mem.startsWith(u8, op_str, "%[")) {
- const mod_index = mem.indexOf(u8, op_str, "]@");
+ const mod_index = mem.find(u8, op_str, "]@");
const modifier = if (mod_index) |index|
op_str[index + "]@".len ..]
else
diff --git a/src/codegen/x86_64/CodeGen.zig b/src/codegen/x86_64/CodeGen.zig
index 4958d17e304cb7cccc3e4b383bd46e1d09141c0a..095de8590a768c68a010bb375f07cf0206c83a10 100644
--- a/src/codegen/x86_64/CodeGen.zig
+++ b/src/codegen/x86_64/CodeGen.zig
@@ -177899,7 +177899,7 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {
else if (std.mem.endsWith(u8, mnem_str, "l"))
.dword
else if (std.mem.endsWith(u8, mnem_str, "q") and
- (std.mem.indexOfScalar(u8, "vp", mnem_str[0]) == null or
+ (std.mem.findScalar(u8, "vp", mnem_str[0]) == null or
!std.mem.endsWith(u8, mnem_str, "dq")))
.qword
else if (std.mem.endsWith(u8, mnem_str, "t"))
@@ -177966,8 +177966,8 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {
}) + 1,
}
};
- const untrimmed_op_str = if (std.mem.indexOfScalar(u8, full_op_str, '#') orelse
- std.mem.indexOf(u8, full_op_str, "//")) |comment|
+ const untrimmed_op_str = if (std.mem.findScalar(u8, full_op_str, '#') orelse
+ std.mem.find(u8, full_op_str, "//")) |comment|
untrimmed_op_str: {
ops_index = ops_str.len;
break :untrimmed_op_str full_op_str[0..comment];
@@ -177976,7 +177976,7 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {
if (trimmed_op_str.len > 0) break trimmed_op_str;
};
if (std.mem.startsWith(u8, op_str, "%%")) {
- const colon = std.mem.indexOfScalarPos(u8, op_str, "%%".len + 2, ':');
+ const colon = std.mem.findScalarPos(u8, op_str, "%%".len + 2, ':');
const reg = parseRegName(op_str["%%".len .. colon orelse op_str.len]) orelse
return self.fail("invalid register: '{s}'", .{op_str});
if (colon) |colon_pos| {
@@ -177997,7 +177997,7 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {
op.* = .{ .reg = reg };
}
} else if (std.mem.startsWith(u8, op_str, "%[") and std.mem.endsWith(u8, op_str, "]")) {
- const colon = std.mem.indexOfScalarPos(u8, op_str, "%[".len, ':');
+ const colon = std.mem.findScalarPos(u8, op_str, "%[".len, ':');
const modifier = if (colon) |colon_pos|
op_str[colon_pos + ":".len .. op_str.len - "]".len]
else
@@ -178080,7 +178080,7 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {
else |_|
return self.fail("invalid immediate: '{s}'", .{op_str});
} else if (std.mem.endsWith(u8, op_str, ")")) {
- const open = std.mem.indexOfScalar(u8, op_str, '(') orelse
+ const open = std.mem.findScalar(u8, op_str, '(') orelse
return self.fail("invalid operand: '{s}'", .{op_str});
var sib_it =
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 {
.disp = if (std.mem.startsWith(u8, op_str[0..open], "%[") and
std.mem.endsWith(u8, op_str[0..open], "]"))
disp: {
- const colon = std.mem.indexOfScalarPos(u8, op_str[0..open], "%[".len, ':');
+ const colon = std.mem.findScalarPos(u8, op_str[0..open], "%[".len, ':');
const modifier = if (colon) |colon_pos|
op_str[colon_pos + ":".len .. open - "]".len]
else
@@ -178210,14 +178210,14 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {
.{ ._, .pseudo }
else for (std.enums.values(Mir.Inst.Fixes)) |fixes| {
const fixes_name = @tagName(fixes);
- const space_index = std.mem.indexOfScalar(u8, fixes_name, ' ');
+ const space_index = std.mem.findScalar(u8, fixes_name, ' ');
const fixes_prefix = if (space_index) |index|
std.meta.stringToEnum(encoder.Instruction.Prefix, fixes_name[0..index]).?
else
.none;
if (fixes_prefix != prefix) continue;
const pattern = fixes_name[if (space_index) |index| index + " ".len else 0..];
- const wildcard_index = std.mem.indexOfScalar(u8, pattern, '_').?;
+ const wildcard_index = std.mem.findScalar(u8, pattern, '_').?;
const mnem_prefix = pattern[0..wildcard_index];
const mnem_suffix = pattern[wildcard_index + "_".len ..];
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
.sse => switch (ty.zigTypeTag(zcu)) {
else => {
const classes = std.mem.sliceTo(&abi.classifySystemV(ty, zcu, cg.target, .other), .none);
- assert(std.mem.indexOfNone(abi.Class, classes, &.{
+ assert(std.mem.findNone(abi.Class, classes, &.{
.integer, .sse, .sseup, .memory, .float, .float_combine,
}) == null);
const abi_size = ty.abiSize(zcu);
- if (abi_size < 4 or std.mem.indexOfScalar(abi.Class, classes, .integer) != null) switch (abi_size) {
+ if (abi_size < 4 or std.mem.findScalar(abi.Class, classes, .integer) != null) switch (abi_size) {
1 => return if (cg.hasFeature(.avx)) .{ .vex_insert_extract = .{
.insert = .{ .vp_b, .insr },
.extract = .{ .vp_b, .extr },
@@ -183578,8 +183578,8 @@ const Temp = struct {
const class = classes[class_index];
next_class_index = @intCast(switch (class) {
.integer, .memory, .float, .float_combine => class_index + 1,
- .sse => std.mem.indexOfNonePos(abi.Class, classes, class_index + 1, &.{.sseup}) orelse classes.len,
- .x87 => std.mem.indexOfNonePos(abi.Class, classes, class_index + 1, &.{.x87up}) orelse classes.len,
+ .sse => std.mem.findNonePos(abi.Class, classes, class_index + 1, &.{.sseup}) orelse classes.len,
+ .x87 => std.mem.findNonePos(abi.Class, classes, class_index + 1, &.{.x87up}) orelse classes.len,
.sseup,
.x87up,
.none,
@@ -189825,7 +189825,7 @@ const Select = struct {
s.cg.asmOps(mir_tag, mir_ops) catch |err| switch (err) {
error.InvalidInstruction => {
const fixes = @tagName(mir_tag[0]);
- const fixes_blank = std.mem.indexOfScalar(u8, fixes, '_').?;
+ const fixes_blank = std.mem.findScalar(u8, fixes, '_').?;
return s.cg.fail("invalid instruction: '{s}{s}{s} {s} {s} {s} {s}'", .{
fixes[0..fixes_blank],
@tagName(mir_tag[1]),
@@ -189905,7 +189905,7 @@ const Select = struct {
.add, .com, .comi, .div, .divr, .mul, .st, .sub, .subr, .ucom, .ucomi => s.top +%= 1,
else => {
const fixes = @tagName(mir_tag[0]);
- const fixes_blank = std.mem.indexOfScalar(u8, fixes, '_').?;
+ const fixes_blank = std.mem.findScalar(u8, fixes, '_').?;
std.debug.panic("{s}: {s}{s}{s}\n", .{
@src().fn_name,
fixes[0..fixes_blank],
diff --git a/src/codegen/x86_64/Lower.zig b/src/codegen/x86_64/Lower.zig
index f471d990d1f19bd10d120d2d69f53266ab5538d3..389d57f62d6540f7f5dc096d65c59402f72ab06b 100644
--- a/src/codegen/x86_64/Lower.zig
+++ b/src/codegen/x86_64/Lower.zig
@@ -435,11 +435,11 @@ const mnemonic_table: [inst_tags_len * inst_fixes_len]?Mnemonic = table: {
for (0..inst_fixes_len) |fixes_i| {
const fixes: Mir.Inst.Fixes = @fromBackingInt(@intCast(fixes_i));
const prefix, const suffix = affix: {
- const pattern = if (std.mem.indexOfScalar(u8, @tagName(fixes), ' ')) |i|
+ const pattern = if (std.mem.findScalar(u8, @tagName(fixes), ' ')) |i|
@tagName(fixes)[i + 1 ..]
else
@tagName(fixes);
- const wildcard_idx = std.mem.indexOfScalar(u8, pattern, '_').?;
+ const wildcard_idx = std.mem.findScalar(u8, pattern, '_').?;
break :affix .{ pattern[0..wildcard_idx], pattern[wildcard_idx + 1 ..] };
};
for (0..inst_tags_len) |inst_tag_i| {
@@ -477,7 +477,7 @@ fn generic(lower: *Lower, inst: Mir.Inst) Error!void {
else => return lower.fail("TODO lower .{s}", .{@tagName(inst.ops)}),
};
try lower.encode(switch (fixes) {
- inline else => |tag| comptime if (std.mem.indexOfScalar(u8, @tagName(tag), ' ')) |space|
+ inline else => |tag| comptime if (std.mem.findScalar(u8, @tagName(tag), ' ')) |space|
@field(Prefix, @tagName(tag)[0..space])
else
.none,
@@ -487,8 +487,8 @@ fn generic(lower: *Lower, inst: Mir.Inst) Error!void {
}
// This combination is invalid; make the theoretical mnemonic name and emit an error with it.
const fixes_name = @tagName(fixes);
- const pattern = fixes_name[if (std.mem.indexOfScalar(u8, fixes_name, ' ')) |i| i + " ".len else 0..];
- const wildcard_index = std.mem.indexOfScalar(u8, pattern, '_').?;
+ const pattern = fixes_name[if (std.mem.findScalar(u8, fixes_name, ' ')) |i| i + " ".len else 0..];
+ const wildcard_index = std.mem.findScalar(u8, pattern, '_').?;
return lower.fail("unsupported mnemonic: '{s}{s}{s}'", .{
pattern[0..wildcard_index],
@tagName(inst.tag),
diff --git a/src/codegen/x86_64/Mir.zig b/src/codegen/x86_64/Mir.zig
index 90fbbdf3125b2e449dc9723a0b98ce26a6b228c2..274437d54ccf55ce4fb47470e7a82b607c4bf0d2 100644
--- a/src/codegen/x86_64/Mir.zig
+++ b/src/codegen/x86_64/Mir.zig
@@ -1745,8 +1745,8 @@ pub const Inst = struct {
for (@typeInfo(Mnemonic).@"enum".field_names) |mnemonic_name| {
if (mnemonic_name[0] == '.') continue;
for (@typeInfo(Fixes).@"enum".field_names) |fixes_name| {
- const pattern = fixes_name[if (std.mem.indexOfScalar(u8, fixes_name, ' ')) |index| index + " ".len else 0..];
- const wildcard_index = std.mem.indexOfScalar(u8, pattern, '_').?;
+ const pattern = fixes_name[if (std.mem.findScalar(u8, fixes_name, ' ')) |index| index + " ".len else 0..];
+ const wildcard_index = std.mem.findScalar(u8, pattern, '_').?;
const mnem_prefix = pattern[0..wildcard_index];
const mnem_suffix = pattern[wildcard_index + "_".len ..];
if (!std.mem.startsWith(u8, mnemonic_name, mnem_prefix)) continue;
@@ -1823,7 +1823,7 @@ pub const NullTerminatedString = enum(u32) {
pub fn toSlice(nts: NullTerminatedString, mir: *const Mir) ?[:0]const u8 {
if (nts == .none) return null;
const string_bytes = mir.string_bytes[@backingInt(nts)..];
- return string_bytes[0..std.mem.indexOfScalar(u8, string_bytes, 0).? :0];
+ return string_bytes[0..std.mem.findScalar(u8, string_bytes, 0).? :0];
}
};
diff --git a/src/codegen/x86_64/abi.zig b/src/codegen/x86_64/abi.zig
index 1e01ff508af3a29367f9cfbb1ea74d412147d70a..3ebad4dee2a9235f641e12be27684d247bfd2de1 100644
--- a/src/codegen/x86_64/abi.zig
+++ b/src/codegen/x86_64/abi.zig
@@ -318,7 +318,7 @@ pub fn classifySystemV(ty: Type, zcu: *Zcu, target: *const std.Target, ctx: Cont
// byte isn't SSE or any other eightbyte isn't SSEUP, the whole argument
// is passed in memory."
if (ty_size > 16 and (result[0] != .sse or
- std.mem.indexOfNone(Class, result[1..], &.{ .sseup, .none }) != null)) return Class.stack;
+ std.mem.findNone(Class, result[1..], &.{ .sseup, .none }) != null)) return Class.stack;
// "If SSEUP is not preceded by SSE or SSEUP, it is converted to SSE."
for (&result, 0..) |*class, i| switch (class.*) {
diff --git a/src/codegen/x86_64/encoder.zig b/src/codegen/x86_64/encoder.zig
index d18497cf08b640064083c4322feaab825f0bb849..a3c8a34714bdc033c5105ddf65e20f5b30e198eb 100644
--- a/src/codegen/x86_64/encoder.zig
+++ b/src/codegen/x86_64/encoder.zig
@@ -1171,7 +1171,7 @@ fn expectEqualHexStrings(expected: []const u8, given: []const u8, assembly: []co
defer testing.allocator.free(expected_fmt);
const given_fmt = try std.fmt.allocPrint(testing.allocator, "{x}", .{given});
defer testing.allocator.free(given_fmt);
- const idx = std.mem.indexOfDiff(u8, expected_fmt, given_fmt).?;
+ const idx = std.mem.findDiff(u8, expected_fmt, given_fmt).?;
const padding = try testing.allocator.alloc(u8, idx + 5);
defer testing.allocator.free(padding);
@memset(padding, ' ');
diff --git a/src/libs/mingw/Preprocessor.zig b/src/libs/mingw/Preprocessor.zig
index 9098b6013a4179ba15de85707d70d290f09bd116..f6606eb54cd0f2ea46a85194dd79674115256499 100644
--- a/src/libs/mingw/Preprocessor.zig
+++ b/src/libs/mingw/Preprocessor.zig
@@ -15,7 +15,7 @@ const RawTokenList = std.ArrayList(Token);
const ExpandBuf = std.ArrayList(Token);
const Preprocessor = @This();
-const DefineMap = std.StringArrayHashMapUnmanaged(Macro);
+const DefineMap = std.array_hash_map.String(Macro);
const GeneratedTokens = std.ArrayList(u8);
@@ -29,7 +29,7 @@ pub const Source = struct {
buf: []const u8,
};
-sources: std.StringArrayHashMapUnmanaged(Source) = .empty,
+sources: std.array_hash_map.String(Source) = .empty,
arena: Allocator,
io: std.Io,
diff --git a/src/libs/mingw/def.zig b/src/libs/mingw/def.zig
index f1c112d16e0e49249faeaaf159f7e2b79e277861..0d67f4fe33539c9a7a25b648a6306f1251187333 100644
--- a/src/libs/mingw/def.zig
+++ b/src/libs/mingw/def.zig
@@ -61,7 +61,7 @@ pub const ModuleDefinition = struct {
// or ? for C++ functions). Vectorcall functions won't have any
// fixed prefix, but the function base name will still be at least
// one char.
- const name_len_without_at_suffix = std.mem.indexOfScalarPos(u8, e.name, 1, '@') orelse e.name.len;
+ const name_len_without_at_suffix = std.mem.findScalarPos(u8, e.name, 1, '@') orelse e.name.len;
e.name = e.name[0..name_len_without_at_suffix];
}
}
@@ -452,7 +452,7 @@ pub const Parser = struct {
var ext_name_needs_underscore = false;
if (self.machine_type == .I386) {
const is_decorated = isDecorated(name_tok.slice(self.tokenizer.source), self.module_definition_type);
- const is_forward_target = ext_name_tok != null and std.mem.indexOfScalar(u8, name_tok.slice(self.tokenizer.source), '.') != null;
+ const is_forward_target = ext_name_tok != null and std.mem.findScalar(u8, name_tok.slice(self.tokenizer.source), '.') != null;
name_needs_underscore = !is_decorated and !is_forward_target;
if (ext_name_tok) |ext_name| {
@@ -578,9 +578,9 @@ pub const Parser = struct {
// themselves can start with an underscore, while a second one still needs
// to be added.
if (std.mem.startsWith(u8, symbol, "@")) return true;
- if (std.mem.indexOf(u8, symbol, "@@") != null) return true;
+ if (std.mem.find(u8, symbol, "@@") != null) return true;
if (std.mem.startsWith(u8, symbol, "?")) return true;
- if (module_definition_type != .mingw and std.mem.indexOfScalar(u8, symbol, '@') != null) return true;
+ if (module_definition_type != .mingw and std.mem.findScalar(u8, symbol, '@') != null) return true;
return false;
}
diff --git a/src/libs/mingw/implib.zig b/src/libs/mingw/implib.zig
index f8ee4858e66d84de84c337c92f04e7c5363442e1..0a4deb7aeb87ac62939fc7a8fd1f6e3d6a1a7966 100644
--- a/src/libs/mingw/implib.zig
+++ b/src/libs/mingw/implib.zig
@@ -351,7 +351,7 @@ fn getNameType(
// the leading underscore. In MinGW on the other hand, a decorated
// stdcall function still omits the underscore (IMPORT_NAME_NOPREFIX).
if (std.mem.startsWith(u8, ext_name, "_") and
- std.mem.indexOfScalar(u8, ext_name, '@') != null and
+ std.mem.findScalar(u8, ext_name, '@') != null and
module_definition_type != .mingw)
return .NAME;
if (!std.mem.eql(u8, symbol, ext_name))
diff --git a/src/link/Coff.zig b/src/link/Coff.zig
index ad85216499ff793a0737fa4082814bfbd1a001e4..729e6393845bdcd5d8edbf98ea8fa126f718e978 100644
--- a/src/link/Coff.zig
+++ b/src/link/Coff.zig
@@ -621,7 +621,7 @@ pub const LongNamesTable = struct {
}
pub fn hash(_: Adapter, key: []const u8) u32 {
- assert(std.mem.indexOfScalar(u8, key, 0) == null);
+ assert(std.mem.findScalar(u8, key, 0) == null);
return std.array_hash_map.hashString(key);
}
};
@@ -711,7 +711,7 @@ pub const ExportTable = struct {
}
pub fn hash(_: Adapter, key: []const u8) u32 {
- assert(std.mem.indexOfScalar(u8, key, 0) == null);
+ assert(std.mem.findScalar(u8, key, 0) == null);
return std.array_hash_map.hashString(key);
}
};
@@ -759,7 +759,7 @@ pub const ImportTable = struct {
}
pub fn hash(_: Adapter, key: []const u8) u32 {
- assert(std.mem.indexOfScalar(u8, key, 0) == null);
+ assert(std.mem.findScalar(u8, key, 0) == null);
return std.array_hash_map.hashString(key);
}
};
@@ -822,7 +822,7 @@ pub const String = enum(u32) {
pub fn toSlice(s: String, coff: *Coff) [:0]const u8 {
const slice = coff.string_bytes.items[@backingInt(s)..];
- return slice[0..std.mem.indexOfScalar(u8, slice, 0).? :0];
+ return slice[0..std.mem.findScalar(u8, slice, 0).? :0];
}
pub fn toOptional(s: String) String.Optional {
@@ -3535,7 +3535,7 @@ fn objectSectionParentName(coff: *Coff, name: []const u8) []const u8 {
// Otherwise, we want to keep the full name so that this sort can occur correctly when
// the object is finally linked into an image.
return if (coff.isImage())
- name[0 .. std.mem.indexOfScalar(u8, name, '$') orelse name.len]
+ name[0 .. std.mem.findScalar(u8, name, '$') orelse name.len]
else
name;
}
@@ -5737,7 +5737,7 @@ fn reportUndefs(coff: *Coff, tid: Zcu.PerThread.Id) !void {
const gpa = comp.gpa;
const max_notes = 4;
- var undef_indices: std.ArrayListUnmanaged(u32) = .empty;
+ var undef_indices: std.ArrayList(u32) = .empty;
for (coff.relocs.items, 0..) |reloc, reloc_i| {
if (reloc.flags.free) continue;
const target_sym = reloc.target.get(coff);
@@ -6987,7 +6987,7 @@ fn flushMoved(coff: *Coff, ni: MappedFile.Node.Index) !void {
continue;
import_hint_name_index = @intCast(import_hint_name_align.forward(
- std.mem.indexOfScalarPos(
+ std.mem.findScalarPos(
u8,
import_hint_name_slice,
import_hint_name_index,
diff --git a/src/link/Elf.zig b/src/link/Elf.zig
index e22680a44a450739239051ad62d27067d2efe327..04d4f9235e12f22c3ee7f012c48d43f323ea38a1 100644
--- a/src/link/Elf.zig
+++ b/src/link/Elf.zig
@@ -2173,7 +2173,7 @@ fn sortInitFini(self: *Elf) !void {
=> is_init_fini = true,
else => {
const name = self.getShString(shdr.sh_name);
- is_ctor_dtor = mem.indexOf(u8, name, ".ctors") != null or mem.indexOf(u8, name, ".dtors") != null;
+ is_ctor_dtor = mem.find(u8, name, ".ctors") != null or mem.find(u8, name, ".dtors") != null;
},
}
if (!is_init_fini and !is_ctor_dtor) continue;
@@ -3702,7 +3702,7 @@ fn shString(
off: u32,
) [:0]const u8 {
const slice = shstrtab[off..];
- return slice[0..mem.indexOfScalar(u8, slice, 0).? :0];
+ return slice[0..mem.findScalar(u8, slice, 0).? :0];
}
pub fn insertShString(self: *Elf, name: [:0]const u8) error{OutOfMemory}!u32 {
@@ -4376,7 +4376,7 @@ fn createThunks(elf_file: *Elf, atom_list: *AtomList) !void {
pub fn stringTableLookup(strtab: []const u8, off: u32) [:0]const u8 {
const slice = strtab[off..];
- return slice[0..mem.indexOfScalar(u8, slice, 0).? :0];
+ return slice[0..mem.findScalar(u8, slice, 0).? :0];
}
pub fn pwriteAll(elf_file: *Elf, bytes: []const u8, offset: u64) error{AlreadyReported}!void {
diff --git a/src/link/Elf/Archive.zig b/src/link/Elf/Archive.zig
index ae997c5b9bc16e806ca86d0889ff95df094dafdf..7be90fc558f72eaabeec930aa83f6e7f5e71b975 100644
--- a/src/link/Elf/Archive.zig
+++ b/src/link/Elf/Archive.zig
@@ -118,7 +118,7 @@ pub fn parse(
pub fn stringTableLookup(strtab: []const u8, off: u32) [:'\n']const u8 {
const slice = strtab[off..];
- return slice[0..mem.indexOfScalar(u8, slice, '\n').? :'\n'];
+ return slice[0..mem.findScalar(u8, slice, '\n').? :'\n'];
}
pub fn setArHdr(opts: struct {
diff --git a/src/link/Elf2.zig b/src/link/Elf2.zig
index be921d285bf96e557a24a04ed53a3f84052bfa2a..b0085f18a404a767553ffbf99ccc63bea7672e2a 100644
--- a/src/link/Elf2.zig
+++ b/src/link/Elf2.zig
@@ -3010,7 +3010,7 @@ const StringTable = struct {
}
pub fn hash(_: Adapter, key: []const u8) u64 {
- assert(std.mem.indexOfScalar(u8, key, 0) == null);
+ assert(std.mem.findScalar(u8, key, 0) == null);
return std.hash_map.hashString(key);
}
};
diff --git a/src/link/MachO.zig b/src/link/MachO.zig
index 77441748d57ef2ad1823f01d2bad18c3b9c1a5e5..3dddf5f78ebc396599c14c666f4b15c082fbce0f 100644
--- a/src/link/MachO.zig
+++ b/src/link/MachO.zig
@@ -1070,7 +1070,7 @@ fn isHoisted(self: *MachO, install_name: []const u8) bool {
if (mem.startsWith(u8, dirname, "/usr/lib")) return true;
if (eatPrefix(dirname, "/System/Library/Frameworks/")) |path| {
const basename = fs.path.basename(install_name);
- if (mem.indexOfScalar(u8, path, '.')) |index| {
+ if (mem.findScalar(u8, path, '.')) |index| {
if (mem.eql(u8, basename, path[0..index])) return true;
}
}
@@ -1739,14 +1739,14 @@ fn initSyntheticSections(self: *MachO) !void {
});
}
} else if (eatPrefix(name, "section$start$")) |actual_name| {
- const sep = mem.indexOfScalar(u8, actual_name, '$').?; // TODO error rather than a panic
+ const sep = mem.findScalar(u8, actual_name, '$').?; // TODO error rather than a panic
const segname = actual_name[0..sep]; // TODO check segname is valid
const sectname = actual_name[sep + 1 ..]; // TODO check sectname is valid
if (self.getSectionByName(segname, sectname) == null) {
_ = try self.addSection(segname, sectname, .{});
}
} else if (eatPrefix(name, "section$end$")) |actual_name| {
- const sep = mem.indexOfScalar(u8, actual_name, '$').?; // TODO error rather than a panic
+ const sep = mem.findScalar(u8, actual_name, '$').?; // TODO error rather than a panic
const segname = actual_name[0..sep]; // TODO check segname is valid
const sectname = actual_name[sep + 1 ..]; // TODO check sectname is valid
if (self.getSectionByName(segname, sectname) == null) {
@@ -1767,7 +1767,7 @@ fn getSegmentProt(segname: []const u8) macho.vm_prot_t {
fn getSegmentRank(segname: []const u8) u8 {
if (mem.eql(u8, segname, "__PAGEZERO")) return 0x0;
if (mem.eql(u8, segname, "__LINKEDIT")) return 0xf;
- if (mem.indexOf(u8, segname, "ZIG")) |_| return 0xe;
+ if (mem.find(u8, segname, "ZIG")) |_| return 0xe;
if (mem.startsWith(u8, segname, "__TEXT")) return 0x1;
if (mem.startsWith(u8, segname, "__DATA_CONST")) return 0x2;
if (mem.startsWith(u8, segname, "__DATA")) return 0x3;
@@ -2342,7 +2342,7 @@ fn allocateSyntheticSymbols(self: *MachO) void {
}
} else if (mem.startsWith(u8, name, "section$start$")) {
const actual_name = name["section$start$".len..];
- const sep = mem.indexOfScalar(u8, actual_name, '$').?; // TODO error rather than a panic
+ const sep = mem.findScalar(u8, actual_name, '$').?; // TODO error rather than a panic
const segname = actual_name[0..sep];
const sectname = actual_name[sep + 1 ..];
if (self.getSectionByName(segname, sectname)) |sect_id| {
@@ -2352,7 +2352,7 @@ fn allocateSyntheticSymbols(self: *MachO) void {
}
} else if (mem.startsWith(u8, name, "section$end$")) {
const actual_name = name["section$end$".len..];
- const sep = mem.indexOfScalar(u8, actual_name, '$').?; // TODO error rather than a panic
+ const sep = mem.findScalar(u8, actual_name, '$').?; // TODO error rather than a panic
const segname = actual_name[0..sep];
const sectname = actual_name[sep + 1 ..];
if (self.getSectionByName(segname, sectname)) |sect_id| {
diff --git a/src/link/MachO/Archive.zig b/src/link/MachO/Archive.zig
index a733e1a5b6c9b3911e27e5e60e1ae4e6faed54a5..91860f45986b106bed46fbf37e9ac35133ff5b49 100644
--- a/src/link/MachO/Archive.zig
+++ b/src/link/MachO/Archive.zig
@@ -45,7 +45,7 @@ pub fn unpack(self: *Archive, macho_file: *MachO, path: Path, handle_index: File
const amt = try handle.readPositionalAll(io, buf, pos);
if (amt != len) return error.InputOutput;
pos += len;
- const actual_len = mem.indexOfScalar(u8, buf, @as(u8, 0)) orelse len;
+ const actual_len = mem.findScalar(u8, buf, @as(u8, 0)) orelse len;
break :name buf[0..actual_len];
}
unreachable;
@@ -161,7 +161,7 @@ pub const ar_hdr = extern struct {
fn name(self: *const ar_hdr) ?[]const u8 {
const value = &self.ar_name;
if (mem.startsWith(u8, value, "#1/")) return null;
- const sentinel = mem.indexOfScalar(u8, value, '/') orelse value.len;
+ const sentinel = mem.findScalar(u8, value, '/') orelse value.len;
return value[0..sentinel];
}
diff --git a/src/link/MachO/Symbol.zig b/src/link/MachO/Symbol.zig
index 7ac8e28881417cde1fcb9da5a9cc90eaf43b8036..60172cf6382342fc6f40080b31724d8369a504ea 100644
--- a/src/link/MachO/Symbol.zig
+++ b/src/link/MachO/Symbol.zig
@@ -43,7 +43,7 @@ pub fn isSymbolStab(symbol: Symbol, macho_file: *MachO) bool {
pub fn isTlvInit(symbol: Symbol, macho_file: *MachO) bool {
const name = symbol.getName(macho_file);
- return std.mem.indexOf(u8, name, "$tlv$init") != null;
+ return std.mem.find(u8, name, "$tlv$init") != null;
}
pub fn weakRef(symbol: Symbol, macho_file: *MachO) bool {
diff --git a/src/link/MachO/dyld_info/Trie.zig b/src/link/MachO/dyld_info/Trie.zig
index b1fdc18d7593608ea6b3eb732adb46548096352d..92c22967f3e23647d84b399ffdc6ac92a60f2f8e 100644
--- a/src/link/MachO/dyld_info/Trie.zig
+++ b/src/link/MachO/dyld_info/Trie.zig
@@ -54,7 +54,7 @@ fn putNode(self: *Trie, node_index: Node.Index, allocator: Allocator, label: []c
// Check for match with edges from this node.
for (self.nodes.items(.edges)[node_index].items) |edge_index| {
const edge = &self.edges.items[edge_index];
- const match = mem.indexOfDiff(u8, edge.label, label) orelse return edge.node;
+ const match = mem.findDiff(u8, edge.label, label) orelse return edge.node;
if (match == 0) continue;
if (match == edge.label.len) return self.putNode(edge.node, allocator, label[match..]);
@@ -351,7 +351,7 @@ fn expectEqualHexStrings(expected: []const u8, given: []const u8) !void {
defer testing.allocator.free(expected_fmt);
const given_fmt = try std.fmt.allocPrint(testing.allocator, "{x}", .{given});
defer testing.allocator.free(given_fmt);
- const idx = mem.indexOfDiff(u8, expected_fmt, given_fmt).?;
+ const idx = mem.findDiff(u8, expected_fmt, given_fmt).?;
const padding = try testing.allocator.alloc(u8, idx + 5);
defer testing.allocator.free(padding);
@memset(padding, ' ');
diff --git a/src/link/SpirV.zig b/src/link/SpirV.zig
index 10d01c2055ff5bf5c1d3734b4a4ae43411d8cc14..aecbc039266604cc905586b71032e91d83b096d0 100644
--- a/src/link/SpirV.zig
+++ b/src/link/SpirV.zig
@@ -25,10 +25,10 @@ const Mir = @import("../codegen/spirv/Mir.zig");
const Linker = @This();
base: link.File,
-fragments: std.AutoArrayHashMapUnmanaged(InternPool.Nav.Index, Mir) = .empty,
-pending_navs: std.ArrayListUnmanaged(InternPool.Nav.Index) = .empty,
-entry_points: std.ArrayListUnmanaged(EntryPointDecl) = .empty,
-external_objects: std.ArrayListUnmanaged(ExternalObject) = .empty,
+fragments: std.array_hash_map.Auto(InternPool.Nav.Index, Mir) = .empty,
+pending_navs: std.ArrayList(InternPool.Nav.Index) = .empty,
+entry_points: std.ArrayList(EntryPointDecl) = .empty,
+external_objects: std.ArrayList(ExternalObject) = .empty,
const EntryPointDecl = struct {
nav: InternPool.Nav.Index,
@@ -363,16 +363,16 @@ fn mergeFragments(linker: *Linker, gpa: Allocator, arena: Allocator) error{OutOf
}
// Resolve Zig extern navs against external objects.
- var ext_id_offsets: std.ArrayListUnmanaged(Word) = .empty;
+ var ext_id_offsets: std.ArrayList(Word) = .empty;
defer ext_id_offsets.deinit(gpa);
try ext_id_offsets.ensureTotalCapacity(gpa, linker.external_objects.items.len);
var unresolved_extern_count: u32 = 0;
- var resolved_ids: std.AutoArrayHashMapUnmanaged(Id, void) = .empty;
+ var resolved_ids: std.array_hash_map.Auto(Id, void) = .empty;
defer resolved_ids.deinit(gpa);
if (maybe_ip) |ip| {
- var extern_name_map: std.StringArrayHashMapUnmanaged(InternPool.Nav.Index) = .empty;
+ var extern_name_map: std.array_hash_map.String(InternPool.Nav.Index) = .empty;
defer extern_name_map.deinit(gpa);
var nav_it = nav_final_ids.iterator();
@@ -518,14 +518,14 @@ fn mergeZigFragments(
frag_infos: []const FragmentInfo,
nav_final_ids: *const std.AutoHashMapUnmanaged(InternPool.Nav.Index, Id),
uav_final_ids: *const std.AutoHashMapUnmanaged(struct { InternPool.Index, spec.StorageClass }, Id),
- resolved_ids: *const std.AutoArrayHashMapUnmanaged(Id, void),
+ resolved_ids: *const std.array_hash_map.Auto(Id, void),
maybe_ip: ?*InternPool,
) error{OutOfMemory}!void {
for (linker.fragments.values(), frag_infos) |*mir, frag_info| {
var id_remap: std.AutoHashMapUnmanaged(Id, Id) = .empty;
defer id_remap.deinit(gpa);
- var resolved_local_ids: std.AutoArrayHashMapUnmanaged(Id, void) = .empty;
+ var resolved_local_ids: std.array_hash_map.Auto(Id, void) = .empty;
defer resolved_local_ids.deinit(gpa);
for (mir.nav_refs) |ref| {
@@ -569,7 +569,7 @@ fn remapFilteredInsts(
id_offset: Word,
id_remap: *const std.AutoHashMapUnmanaged(Id, Id),
parser: *BinaryModule.Parser,
- skip_ids: *const std.AutoArrayHashMapUnmanaged(Id, void),
+ skip_ids: *const std.array_hash_map.Auto(Id, void),
mode: FilterMode,
) error{OutOfMemory}!void {
if (words.len == 0) return;
@@ -887,9 +887,9 @@ fn appendExternalObjects(
has_linkage: *bool,
keep_entry_points: bool,
is_obj: bool,
- resolved_ids: *const std.AutoArrayHashMapUnmanaged(Id, void),
+ resolved_ids: *const std.array_hash_map.Auto(Id, void),
) error{OutOfMemory}!void {
- var export_map: std.StringArrayHashMapUnmanaged(Id) = .empty;
+ var export_map: std.array_hash_map.String(Id) = .empty;
defer export_map.deinit(gpa);
for (linker.external_objects.items, ext_id_offsets) |ext_obj, id_offset| {
@@ -908,7 +908,7 @@ fn appendExternalObjects(
}
for (per_obj_remaps) |*m| m.* = .empty;
- var resolved_linkage_ids: std.AutoArrayHashMapUnmanaged(Id, void) = .empty;
+ var resolved_linkage_ids: std.array_hash_map.Auto(Id, void) = .empty;
defer resolved_linkage_ids.deinit(gpa);
for (resolved_ids.keys()) |id| {
diff --git a/src/link/SpirV/dedup_types.zig b/src/link/SpirV/dedup_types.zig
index df0d9a29dd78258acda42be564a14ab748638bce..8841c4185033c8ace7131236f0e549ef10745118 100644
--- a/src/link/SpirV/dedup_types.zig
+++ b/src/link/SpirV/dedup_types.zig
@@ -85,7 +85,7 @@ pub fn run(parser: *BinaryModule.Parser, binary: *BinaryModule) !void {
for (inst.operands, 0..) |word, i| {
if (i == result_id_index) continue;
- if (std.mem.indexOfScalar(u16, id_offsets.items, @intCast(i)) != null) {
+ if (std.mem.findScalar(u16, id_offsets.items, @intCast(i)) != null) {
const canonical = id_remap.get(@fromBackingInt(@intCast(word))) orelse @as(Id, @fromBackingInt(@intCast(word)));
try key_words.append(gpa, @backingInt(canonical));
} else {
@@ -182,7 +182,7 @@ pub fn run(parser: *BinaryModule.Parser, binary: *BinaryModule) !void {
} else null;
for (inst_slice, 0..) |*word, i| {
- if (std.mem.indexOfScalar(u16, id_offsets.items, @intCast(i)) == null) continue;
+ if (std.mem.findScalar(u16, id_offsets.items, @intCast(i)) == null) continue;
max_id = @max(max_id, word.*);
if (maybe_result_id_index != null and i == maybe_result_id_index.?) continue;
diff --git a/src/link/SpirV/prune_unused.zig b/src/link/SpirV/prune_unused.zig
index 2ca052152fdbb371e05a8d8fc5aac95fa8402f11..a41b0d878d07b7c3e3179429dae74e27aaf044b8 100644
--- a/src/link/SpirV/prune_unused.zig
+++ b/src/link/SpirV/prune_unused.zig
@@ -187,7 +187,7 @@ fn markAlive(
parser: *BinaryModule.Parser,
binary: BinaryModule,
inst: BinaryModule.Instruction,
- alive: *std.DynamicBitSetUnmanaged,
+ alive: *std.bit_set.Dynamic,
id_to_index: *const std.AutoHashMapUnmanaged(ResultId, u32),
code_offsets: *const std.ArrayList(usize),
id_offset_buf: *std.ArrayList(u16),
diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig
index 495b9d06603191ca2b503e98f413b9ab3ead52d9..9fba1510ba1f847d2c1ed1cdd2f15eab3c30504f 100644
--- a/src/link/Wasm.zig
+++ b/src/link/Wasm.zig
@@ -2539,14 +2539,14 @@ pub const String = enum(u32) {
}
pub fn hash(_: @This(), adapted_key: []const u8) u64 {
- assert(mem.indexOfScalar(u8, adapted_key, 0) == null);
+ assert(mem.findScalar(u8, adapted_key, 0) == null);
return std.hash_map.hashString(adapted_key);
}
};
pub fn slice(index: String, wasm: *const Wasm) [:0]const u8 {
const start_slice = wasm.string_bytes.items[@backingInt(index)..];
- return start_slice[0..mem.indexOfScalar(u8, start_slice, 0).? :0];
+ return start_slice[0..mem.findScalar(u8, start_slice, 0).? :0];
}
pub fn toOptional(i: String) OptionalString {
@@ -4332,7 +4332,7 @@ pub fn internOptionalString(wasm: *Wasm, optional_bytes: ?[]const u8) Allocator.
}
pub fn internString(wasm: *Wasm, bytes: []const u8) Allocator.Error!String {
- assert(mem.indexOfScalar(u8, bytes, 0) == null);
+ assert(mem.findScalar(u8, bytes, 0) == null);
wasm.string_bytes_lock.lock();
defer wasm.string_bytes_lock.unlock();
const gpa = wasm.base.comp.gpa;
@@ -4363,7 +4363,7 @@ pub fn internStringFmt(wasm: *Wasm, comptime format: []const u8, args: anytype)
}
pub fn getExistingString(wasm: *const Wasm, bytes: []const u8) ?String {
- assert(mem.indexOfScalar(u8, bytes, 0) == null);
+ assert(mem.findScalar(u8, bytes, 0) == null);
return wasm.string_table.getKeyAdapted(bytes, @as(String.TableIndexAdapter, .{
.bytes = wasm.string_bytes.items,
}));
diff --git a/src/link/Wasm/Archive.zig b/src/link/Wasm/Archive.zig
index 65a1ee313b8c6bc5e8710728cd877284c47b544f..48665264f3cab69532a8e70d371fe506578d3ea8 100644
--- a/src/link/Wasm/Archive.zig
+++ b/src/link/Wasm/Archive.zig
@@ -45,7 +45,7 @@ const Header = extern struct {
fn nameOrIndex(archive: Header) !NameOrIndex {
const value = getValue(&archive.name);
- const slash_index = mem.indexOfScalar(u8, value, '/') orelse return error.MalformedArchive;
+ const slash_index = mem.findScalar(u8, value, '/') orelse return error.MalformedArchive;
const len = value.len;
if (slash_index == len - 1) {
// Name stored directly
diff --git a/src/link/Wasm/Flush.zig b/src/link/Wasm/Flush.zig
index 9c15adf65029f90fd95b13f57599bc9bcb6f9bcf..e80d768ae122c3a92ec66ed98e202dc5b6c242ed 100644
--- a/src/link/Wasm/Flush.zig
+++ b/src/link/Wasm/Flush.zig
@@ -1925,7 +1925,7 @@ fn emitProducerSection(gpa: Allocator, binary_bytes: *ArrayList(u8)) !void {
fn splitSegmentName(name: []const u8) struct { []const u8, []const u8 } {
const start = @intFromBool(name.len >= 1 and name[0] == '.');
- const pivot = mem.indexOfScalarPos(u8, name, start, '.') orelse name.len;
+ const pivot = mem.findScalarPos(u8, name, start, '.') orelse name.len;
return .{ name[0..pivot], name[pivot..] };
}
@@ -2092,7 +2092,7 @@ fn emitTagNameTable(
const ptr_size_bytes: usize = if (is64) 8 else 4;
try code.ensureUnusedCapacity(gpa, ptr_size_bytes * 2 * tag_name_offs.len);
for (tag_name_offs) |off| {
- const name_len: u32 = @intCast(mem.indexOfScalar(u8, tag_name_bytes[off..], 0).?);
+ const name_len: u32 = @intCast(mem.findScalar(u8, tag_name_bytes[off..], 0).?);
if (is64) {
mem.writeInt(u64, code.addManyAsArrayAssumeCapacity(8), base + off, .little);
mem.writeInt(u64, code.addManyAsArrayAssumeCapacity(8), name_len, .little);
@@ -2119,7 +2119,7 @@ fn emitRelocatableNameTable(
try code.ensureUnusedCapacity(gpa, @as(usize, ptr_size) * 2 * name_offs.len);
try relocs.ensureUnusedCapacity(gpa, name_offs.len);
for (name_offs) |off| {
- const name_len: u32 = @intCast(mem.indexOfScalar(u8, name_bytes[off..], 0).?);
+ const name_len: u32 = @intCast(mem.findScalar(u8, name_bytes[off..], 0).?);
const reloc_offset = output_offset + @as(u32, @intCast(code.items.len - table_start));
switch (ptr_size) {
4 => {
diff --git a/src/main.zig b/src/main.zig
index 4faeaebcecd927c8bdd3468ebc32453a74fc9c18..ff915761b592ad2a1f9a6fc66336b26e9b43bc16 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -2148,7 +2148,7 @@ fn buildOutputType(
preprocessor_arg[0] == '-' and
preprocessor_arg[2] != '-')
{
- if (mem.indexOfScalar(u8, preprocessor_arg, '=')) |equals_pos| {
+ if (mem.findScalar(u8, preprocessor_arg, '=')) |equals_pos| {
const key = preprocessor_arg[0..equals_pos];
const value = preprocessor_arg[equals_pos + 1 ..];
try preprocessor_args.append(key);
@@ -2170,7 +2170,7 @@ fn buildOutputType(
linker_arg[0] == '-' and
linker_arg[2] != '-')
{
- if (mem.indexOfScalar(u8, linker_arg, '=')) |equals_pos| {
+ if (mem.findScalar(u8, linker_arg, '=')) |equals_pos| {
const key = linker_arg[0..equals_pos];
const value = linker_arg[equals_pos + 1 ..];
@@ -2378,7 +2378,7 @@ fn buildOutputType(
// Handle joined args like `--dependency-file=foo.d`.
// Must be prefixed with 1 or 2 dashes.
if (it.only_arg.len >= 3 and it.only_arg[0] == '-' and it.only_arg[2] != '-') {
- if (mem.indexOfScalar(u8, it.only_arg, '=')) |equals_pos| {
+ if (mem.findScalar(u8, it.only_arg, '=')) |equals_pos| {
const key = it.only_arg[0..equals_pos];
const value = it.only_arg[equals_pos + 1 ..];
diff --git a/src/target.zig b/src/target.zig
index c64fd988cf4de9c881a8e79041ea8f7b80b099d0..d67766c3691ba6fda8cb86961e889458629d7360 100644
--- a/src/target.zig
+++ b/src/target.zig
@@ -680,14 +680,14 @@ pub fn isDynamicAMDGCNFeature(target: *const std.Target, feature: std.Target.Cpu
const feature_tag: std.Target.amdgcn.Feature = @fromBackingInt(@intCast(feature.index));
if (feature_tag == .sramecc) {
- if (std.mem.indexOfScalar(
+ if (std.mem.findScalar(
*const std.Target.Cpu.Model,
sramecc_only ++ xnack_or_sramecc,
target.cpu.model,
)) |_| return true;
}
if (feature_tag == .xnack) {
- if (std.mem.indexOfScalar(
+ if (std.mem.findScalar(
*const std.Target.Cpu.Model,
xnack_or_sramecc,
target.cpu.model,
diff --git a/test/src/Cases.zig b/test/src/Cases.zig
index af5dcfdddd6fd1c7671f88ff812637bfbcdfd794..c629f42381afb196a4621d6530ba106e788b52b3 100644
--- a/test/src/Cases.zig
+++ b/test/src/Cases.zig
@@ -491,7 +491,7 @@ pub fn lowerToBuildSteps(
for (self.cases.items) |case| {
for (options.test_filters) |test_filter| {
- if (std.mem.indexOf(u8, case.name, test_filter)) |_| break;
+ if (std.mem.find(u8, case.name, test_filter)) |_| break;
} else if (options.test_filters.len > 0) continue;
if (case.case.? == .Error and options.skip_compile_errors) continue;
@@ -524,7 +524,7 @@ pub fn lowerToBuildSteps(
if (options.test_target_filters.len > 0) {
for (options.test_target_filters) |filter| {
- if (std.mem.indexOf(u8, triple_txt, filter) != null) break;
+ if (std.mem.find(u8, triple_txt, filter) != null) break;
} else continue;
}
diff --git a/test/src/Debugger.zig b/test/src/Debugger.zig
index b951e3c86595302d1ee16101f4f810bcaf21ab24..0e20799f3949884c437bbd39931c29f93a41d5b5 100644
--- a/test/src/Debugger.zig
+++ b/test/src/Debugger.zig
@@ -2384,13 +2384,13 @@ fn addTest(
) void {
if (db.options.test_filters.len > 0) {
for (db.options.test_filters) |test_filter| {
- if (std.mem.indexOf(u8, name, test_filter) != null) break;
+ if (std.mem.find(u8, name, test_filter) != null) break;
} else return;
}
if (db.options.test_target_filters.len > 0) {
const triple_txt = target.resolved.query.zigTriple(db.b.allocator) catch @panic("OOM");
for (db.options.test_target_filters) |filter| {
- if (std.mem.indexOf(u8, triple_txt, filter) != null) break;
+ if (std.mem.find(u8, triple_txt, filter) != null) break;
} else return;
}
const files_wf = db.b.addWriteFiles();
diff --git a/test/src/ErrorTrace.zig b/test/src/ErrorTrace.zig
index c4150eded5d4b17fffc2a386d3c7b9411ded6665..b0ce8b05bb39687429ffb8eec893f254d4c4813a 100644
--- a/test/src/ErrorTrace.zig
+++ b/test/src/ErrorTrace.zig
@@ -82,7 +82,7 @@ fn addCaseConfig(
});
if (self.test_filters.len > 0) {
for (self.test_filters) |test_filter| {
- if (mem.indexOf(u8, annotated_case_name, test_filter)) |_| break;
+ if (mem.find(u8, annotated_case_name, test_filter)) |_| break;
} else return;
}
diff --git a/test/src/Libc.zig b/test/src/Libc.zig
index d2113893325821c63a441eba99ea06f1a4610402..12a4468b1f6d33b7494d7fb87b43636533e8ed90 100644
--- a/test/src/Libc.zig
+++ b/test/src/Libc.zig
@@ -49,7 +49,7 @@ pub fn addTarget(libc: *const Libc, target: std.Build.ResolvedTarget) void {
if (libc.options.test_target_filters.len > 0) {
const triple_txt = target.query.zigTriple(libc.b.allocator) catch @panic("OOM");
for (libc.options.test_target_filters) |filter| {
- if (std.mem.indexOf(u8, triple_txt, filter)) |_| break;
+ if (std.mem.find(u8, triple_txt, filter)) |_| break;
} else return;
}
@@ -82,7 +82,7 @@ pub fn addTarget(libc: *const Libc, target: std.Build.ResolvedTarget) void {
const annotated_case_name = libc.b.fmt("run libc-test {s} ({t})", .{ test_case.name, optimize });
for (libc.options.test_filters) |test_filter| {
- if (std.mem.indexOf(u8, annotated_case_name, test_filter)) |_| break;
+ if (std.mem.find(u8, annotated_case_name, test_filter)) |_| break;
} else if (libc.options.test_filters.len > 0) continue;
const mod = libc.b.createModule(.{
diff --git a/test/src/Link.zig b/test/src/Link.zig
index 0c64ae5648333aabf1bfc56090d929341772294c..f0266923e34a380c1e5547c3f180b2d6febbe71c 100644
--- a/test/src/Link.zig
+++ b/test/src/Link.zig
@@ -8,7 +8,7 @@ use_lld: bool,
link_libc: bool,
test_filters: []const []const u8,
update_step: ?*Step.UpdateSourceFiles,
-updated_snapshots: std.StringArrayHashMapUnmanaged(void),
+updated_snapshots: std.array_hash_map.String(void),
max_rss: usize,
pub fn includeTest(self: *Link, prefix: []const u8) ?Case {
diff --git a/test/src/LlvmIr.zig b/test/src/LlvmIr.zig
index 310d6426188bba216465b9c0ea126946c47cf9ca..fc0fddeb32f4893af6b38d1ef80c780fdae4676f 100644
--- a/test/src/LlvmIr.zig
+++ b/test/src/LlvmIr.zig
@@ -77,14 +77,14 @@ pub fn addCase(self: *LlvmIr, case: TestCase) void {
if (self.options.test_target_filters.len > 0) {
const triple_txt = target.query.zigTriple(self.b.allocator) catch @panic("OOM");
for (self.options.test_target_filters) |filter| {
- if (std.mem.indexOf(u8, triple_txt, filter) != null) break;
+ if (std.mem.find(u8, triple_txt, filter) != null) break;
} else return;
}
const name = std.fmt.allocPrint(self.b.allocator, "check llvm-ir {s}", .{case.name}) catch @panic("OOM");
if (self.options.test_filters.len > 0) {
for (self.options.test_filters) |filter| {
- if (std.mem.indexOf(u8, name, filter) != null) break;
+ if (std.mem.find(u8, name, filter) != null) break;
} else return;
}
diff --git a/test/src/RunTranslatedC.zig b/test/src/RunTranslatedC.zig
index 74e059cc599f9cb3edac29c1562b5b6d3adc2551..7d147aeceacf88c2658230ef0d48a7e7ae166bb2 100644
--- a/test/src/RunTranslatedC.zig
+++ b/test/src/RunTranslatedC.zig
@@ -68,7 +68,7 @@ pub fn addCase(self: *RunTranslatedCContext, case: *const TestCase) void {
const annotated_case_name = fmt.allocPrint(self.b.allocator, "run-translated-c {s}", .{case.name}) catch unreachable;
for (self.test_filters) |test_filter| {
- if (mem.indexOf(u8, annotated_case_name, test_filter)) |_| break;
+ if (mem.find(u8, annotated_case_name, test_filter)) |_| break;
} else if (self.test_filters.len > 0) return;
const write_src = b.addWriteFiles();
diff --git a/test/src/StackTrace.zig b/test/src/StackTrace.zig
index a10b70fe280d5594a853e2ca37238891d9af41ff..23938cbf1ade2733f8220bbb03612c183ad7e27a 100644
--- a/test/src/StackTrace.zig
+++ b/test/src/StackTrace.zig
@@ -200,7 +200,7 @@ fn addCaseInstance(
});
if (self.test_filters.len > 0) {
for (self.test_filters) |test_filter| {
- if (mem.indexOf(u8, annotated_case_name, test_filter)) |_| break;
+ if (mem.find(u8, annotated_case_name, test_filter)) |_| break;
} else return;
}
diff --git a/test/src/TranslateC.zig b/test/src/TranslateC.zig
index 57aaea6e0cacf946fc9d351eb9a7db04e4bd407d..c8cc4e3fd009f3dd3f983d042549b45b7da6e571 100644
--- a/test/src/TranslateC.zig
+++ b/test/src/TranslateC.zig
@@ -90,7 +90,7 @@ pub fn addCase(self: *TranslateCContext, case: *const TestCase) void {
const translate_c_cmd = "translate-c";
const annotated_case_name = fmt.allocPrint(self.b.allocator, "{s} {s}", .{ translate_c_cmd, case.name }) catch unreachable;
for (self.test_filters) |test_filter| {
- if (mem.indexOf(u8, annotated_case_name, test_filter)) |_| break;
+ if (mem.find(u8, annotated_case_name, test_filter)) |_| break;
} else if (self.test_filters.len > 0) return;
const target = b.resolveTargetQuery(case.target);
@@ -99,7 +99,7 @@ pub fn addCase(self: *TranslateCContext, case: *const TestCase) void {
const triple_txt = target.query.zigTriple(b.allocator) catch @panic("OOM");
for (self.test_target_filters) |filter| {
- if (std.mem.indexOf(u8, triple_txt, filter) != null) break;
+ if (std.mem.find(u8, triple_txt, filter) != null) break;
} else return;
}
diff --git a/test/src/convert-stack-trace.zig b/test/src/convert-stack-trace.zig
index 5d7356a2d48e92e8577d4c3013a062dec0d63899..e42fd6860c76ce0f8986d06501f310862e39a3ca 100644
--- a/test/src/convert-stack-trace.zig
+++ b/test/src/convert-stack-trace.zig
@@ -52,13 +52,13 @@ pub fn main(init: std.process.Init) !void {
continue;
}
- const src_pos_end = std.mem.indexOf(u8, in_line, ": 0x") orelse {
+ const src_pos_end = std.mem.find(u8, in_line, ": 0x") orelse {
try w.writeAll(in_line);
continue;
};
const src_pos_start = b: {
const postfix = ".zig:";
- const postfix_index = std.mem.lastIndexOf(u8, in_line[0..src_pos_end], postfix) orelse {
+ const postfix_index = std.mem.findLast(u8, in_line[0..src_pos_end], postfix) orelse {
try w.writeAll(in_line);
continue;
};
@@ -89,7 +89,7 @@ pub fn main(init: std.process.Init) !void {
// ...with that first '_' being replaced by its basename.
const src_path = in_line[0..src_pos_start];
- const basename_start = if (std.mem.lastIndexOfAny(u8, src_path, "/\\")) |i| i + 1 else 0;
+ const basename_start = if (std.mem.findLastAny(u8, src_path, "/\\")) |i| i + 1 else 0;
const symbol_start = addr_end + " in ".len;
try w.writeAll(in_line[basename_start..src_pos_end]);
try w.writeAll(": [address] in ");
diff --git a/test/tests.zig b/test/tests.zig
index 90442edf52c9135eaf901c075828191cae6e45f3..b543d0d48f80e74bb943fae1da93a868278e8363 100644
--- a/test/tests.zig
+++ b/test/tests.zig
@@ -2542,13 +2542,13 @@ pub fn addStandaloneTests(
.enable_ios_sdk = enable_ios_sdk,
.enable_macos_sdk = enable_macos_sdk,
.enable_symlinks_windows = enable_symlinks_windows,
- .simple_skip_debug = mem.indexOfScalar(OptimizeMode, optimize_modes, .debug) == null,
- .simple_skip_release_safe = mem.indexOfScalar(OptimizeMode, optimize_modes, .safe) == null,
- .simple_skip_release_fast = mem.indexOfScalar(OptimizeMode, optimize_modes, .fast) == null,
- .simple_skip_release_small = mem.indexOfScalar(OptimizeMode, optimize_modes, .small) == null,
+ .simple_skip_debug = mem.findScalar(OptimizeMode, optimize_modes, .debug) == null,
+ .simple_skip_release_safe = mem.findScalar(OptimizeMode, optimize_modes, .safe) == null,
+ .simple_skip_release_fast = mem.findScalar(OptimizeMode, optimize_modes, .fast) == null,
+ .simple_skip_release_small = mem.findScalar(OptimizeMode, optimize_modes, .small) == null,
});
const test_cases_dep_step = test_cases_dep.builder.default_step;
- test_cases_dep_step.name = b.dupe(test_cases_dep_name);
+ test_cases_dep_step.name = b.graph.dupeString(test_cases_dep_name);
step.dependOn(test_cases_dep.builder.default_step);
}
return step;
@@ -2862,7 +2862,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
if (options.test_target_filters.len > 0) {
for (options.test_target_filters) |filter| {
- if (std.mem.indexOf(u8, triple_txt, filter) != null) break;
+ if (std.mem.find(u8, triple_txt, filter) != null) break;
} else continue;
}
@@ -3160,7 +3160,7 @@ pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step {
if (options.test_target_filters.len > 0) {
for (options.test_target_filters) |filter| {
- if (std.mem.indexOf(u8, triple_txt, filter) != null) break;
+ if (std.mem.find(u8, triple_txt, filter) != null) break;
} else continue;
}
@@ -3249,7 +3249,7 @@ pub fn addLinkTests(b: *std.Build, options: LinkTestOptions) *Step {
if (options.test_target_filters.len > 0) {
for (options.test_target_filters) |filter| {
- if (std.mem.indexOf(u8, triple_txt, filter) != null) break;
+ if (std.mem.find(u8, triple_txt, filter) != null) break;
} else continue;
}
@@ -3374,7 +3374,7 @@ pub fn addIncrementalTests(b: *std.Build, test_step: *Step, test_filters: []cons
if (std.mem.endsWith(u8, entry.basename, ".swp")) continue;
for (test_filters) |test_filter| {
- if (std.mem.indexOf(u8, entry.path, test_filter)) |_| break;
+ if (std.mem.find(u8, entry.path, test_filter)) |_| break;
} else if (test_filters.len > 0) continue;
switch (entry.kind) {
diff --git a/tools/docgen.zig b/tools/docgen.zig
index 9f182f350cc73069a44bfe7b2cc52ade250f228e..5e78dbecc98f37d1d4186011a2601683a29713e1 100644
--- a/tools/docgen.zig
+++ b/tools/docgen.zig
@@ -712,10 +712,10 @@ fn tokenizeAndPrintRaw(
next_tok_is_fn = false;
const token = tokenizer.next();
- if (mem.indexOf(u8, src[index..token.loc.start], "//")) |comment_start_off| {
+ if (mem.find(u8, src[index..token.loc.start], "//")) |comment_start_off| {
// render one comment
const comment_start = index + comment_start_off;
- const comment_end_off = mem.indexOf(u8, src[comment_start..token.loc.start], "\n");
+ const comment_end_off = mem.find(u8, src[comment_start..token.loc.start], "\n");
const comment_end = if (comment_end_off) |o| comment_start + o else token.loc.start;
try writeEscapedLines(out, src[index..comment_start]);
diff --git a/tools/doctest.zig b/tools/doctest.zig
index fcd67e8458a31ea03323b87cbfb222fc31852f94..b653b84a8e3195d01c061921428273d3c351839a 100644
--- a/tools/doctest.zig
+++ b/tools/doctest.zig
@@ -383,7 +383,7 @@ fn printOutput(
fatal("example compile crashed", .{});
},
}
- if (mem.indexOf(u8, result.stderr, error_match) == null) {
+ if (mem.find(u8, result.stderr, error_match) == null) {
print("{s}\nExpected to find '{s}' in stderr\n", .{ result.stderr, error_match });
fatal("example did not have expected compile error", .{});
}
@@ -438,7 +438,7 @@ fn printOutput(
fatal("example compile crashed", .{});
},
}
- if (mem.indexOf(u8, result.stderr, error_match) == null) {
+ if (mem.find(u8, result.stderr, error_match) == null) {
print("{s}\nExpected to find '{s}' in stderr\n", .{ result.stderr, error_match });
fatal("example did not have expected runtime safety error message", .{});
}
@@ -513,7 +513,7 @@ fn printOutput(
fatal("example compile crashed", .{});
},
}
- if (mem.indexOf(u8, result.stderr, error_match) == null) {
+ if (mem.find(u8, result.stderr, error_match) == null) {
print("{s}\nExpected to find '{s}' in stderr\n", .{ result.stderr, error_match });
fatal("example did not have expected compile error message", .{});
}
@@ -623,10 +623,10 @@ fn tokenizeAndPrint(arena: Allocator, out: *Writer, raw_src: []const u8) !void {
next_tok_is_fn = false;
const token = tokenizer.next();
- if (mem.indexOf(u8, src[index..token.loc.start], "//")) |comment_start_off| {
+ if (mem.find(u8, src[index..token.loc.start], "//")) |comment_start_off| {
// render one comment
const comment_start = index + comment_start_off;
- const comment_end_off = mem.indexOf(u8, src[comment_start..token.loc.start], "\n");
+ const comment_end_off = mem.find(u8, src[comment_start..token.loc.start], "\n");
const comment_end = if (comment_end_off) |o| comment_start + o else token.loc.start;
try writeEscapedLines(out, src[index..comment_start]);
@@ -870,13 +870,13 @@ const Code = struct {
};
fn stripManifest(source_bytes: []const u8) []const u8 {
- const manifest_start = mem.lastIndexOf(u8, source_bytes, "\n\n// ") orelse
+ const manifest_start = mem.findLast(u8, source_bytes, "\n\n// ") orelse
fatal("missing manifest comment", .{});
return source_bytes[0 .. manifest_start + 1];
}
fn parseManifest(arena: Allocator, source_bytes: []const u8) !Code {
- const manifest_start = mem.lastIndexOf(u8, source_bytes, "\n\n// ") orelse
+ const manifest_start = mem.findLast(u8, source_bytes, "\n\n// ") orelse
fatal("missing manifest comment", .{});
var it = mem.tokenizeScalar(u8, source_bytes[manifest_start..], '\n');
const first_line = skipPrefix(it.next().?);
@@ -1104,7 +1104,7 @@ fn termColor(allocator: Allocator, input: []const u8) ![]u8 {
// Returns true if number is in slice.
fn in(slice: []const u8, number: u8) bool {
- return mem.indexOfScalar(u8, slice, number) != null;
+ return mem.findScalar(u8, slice, number) != null;
}
fn run(
diff --git a/tools/fetch_them_macos_headers.zig b/tools/fetch_them_macos_headers.zig
index d15bf8b7dfa9f8ccb3acbbb5d978726c16379731..d2b7dd2f933e50d25f5f46f53888abad9986c8f3 100644
--- a/tools/fetch_them_macos_headers.zig
+++ b/tools/fetch_them_macos_headers.zig
@@ -187,8 +187,8 @@ fn fetchTarget(
var it = mem.splitScalar(u8, headers_list_str, '\n');
while (it.next()) |line| {
- if (mem.lastIndexOf(u8, line, "clang") != null) continue;
- if (mem.lastIndexOf(u8, line, prefix[0..])) |idx| {
+ if (mem.findLast(u8, line, "clang") != null) continue;
+ if (mem.findLast(u8, line, prefix[0..])) |idx| {
const out_rel_path = line[idx + prefix.len + 1 ..];
const out_rel_path_stripped = mem.trim(u8, out_rel_path, " \\");
const dirname = Dir.path.dirname(out_rel_path_stripped) orelse ".";
diff --git a/tools/incr-check.zig b/tools/incr-check.zig
index cbc1ec659409eadefd89d516c8816ed36f92d4e5..500635b24972b5a54f69a873489c130e3f39a7f0 100644
--- a/tools/incr-check.zig
+++ b/tools/incr-check.zig
@@ -450,7 +450,7 @@ const Eval = struct {
const raw_filename = eb.nullTerminatedString(src.src_path);
// We need to replace backslashes for consistency between platforms.
const filename = name: {
- if (std.mem.indexOfScalar(u8, raw_filename, '\\') == null) break :name raw_filename;
+ if (std.mem.findScalar(u8, raw_filename, '\\') == null) break :name raw_filename;
const copied = try eval.arena.dupe(u8, raw_filename);
std.mem.replaceScalar(u8, copied, '\\', '/');
break :name copied;
@@ -777,7 +777,7 @@ const Case = struct {
.backend = backend,
});
} else if (std.mem.eql(u8, key, "module")) {
- const split_idx = std.mem.indexOfScalar(u8, val, '=') orelse
+ const split_idx = std.mem.findScalar(u8, val, '=') orelse
fatal("line {d}: module does not include file", .{line_n});
const name = val[0..split_idx];
const file = val[split_idx + 1 ..];
@@ -983,7 +983,7 @@ fn rand64(io: Io) u64 {
fn parseTargetQueryAndBackend(input_str: []const u8, err_prefix: []const u8) struct { std.Target.Query, Backend } {
const fatal = std.process.fatal;
- const split_idx = std.mem.lastIndexOfScalar(u8, input_str, '-') orelse
+ const split_idx = std.mem.findScalarLast(u8, input_str, '-') orelse
fatal("{s}target does not include backend", .{err_prefix});
const query = input_str[0..split_idx];
diff --git a/tools/update_clang_options.zig b/tools/update_clang_options.zig
index 43b81238703433538070330f5d96e3fe4a337f41..a89ec3724ee72099aabe7f5ff50e47625ec1bc75 100644
--- a/tools/update_clang_options.zig
+++ b/tools/update_clang_options.zig
@@ -599,7 +599,7 @@ const known_options = [_]KnownOpt{
const blacklisted_options = [_][]const u8{};
fn knownOption(name: []const u8) ?[]const u8 {
- const chopped_name = if (std.mem.indexOfScalar(u8, name, '=')) |idx| name[0..idx] else name;
+ const chopped_name = if (std.mem.findScalar(u8, name, '=')) |idx| name[0..idx] else name;
for (known_options) |item| {
if (std.mem.eql(u8, chopped_name, item.name)) {
return item.ident;
diff --git a/tools/update_crc_catalog.zig b/tools/update_crc_catalog.zig
index 55f51ce92b4f4a36f51fd176b681487de16d1621..c39008f495d3036cc4d1f9a4b93bfa235117c58d 100644
--- a/tools/update_crc_catalog.zig
+++ b/tools/update_crc_catalog.zig
@@ -99,7 +99,7 @@ fn @"i like cheese"(arena: std.mem.Allocator, io: Io, args: []const []const u8)
var it = mem.splitSequence(u8, line, " ");
while (it.next()) |property| {
- const i = mem.indexOf(u8, property, "=").?;
+ const i = mem.find(u8, property, "=").?;
const key = property[0..i];
const value = property[i + 1 ..];
if (mem.eql(u8, key, "width")) {
|---|