aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/zig/Zir.zig8
1 files changed, 2 insertions, 6 deletions
diff --git a/lib/std/zig/Zir.zig b/lib/std/zig/Zir.zig
index db082b7f8e..64e8a1c805 100644
--- a/lib/std/zig/Zir.zig
+++ b/lib/std/zig/Zir.zig
@@ -106,12 +106,8 @@ pub const NullTerminatedString = enum(u32) {
/// Given an index into `string_bytes` returns the null-terminated string found there.
pub fn nullTerminatedString(code: Zir, index: NullTerminatedString) [:0]const u8 {
- const start = @intFromEnum(index);
- var end: u32 = start;
- while (code.string_bytes[end] != 0) {
- end += 1;
- }
- return code.string_bytes[start..end :0];
+ const slice = code.string_bytes[@intFromEnum(index)..];
+ return slice[0..std.mem.indexOfScalar(u8, slice, 0).? :0];
}
pub fn refSlice(code: Zir, start: usize, len: usize) []Inst.Ref {