aboutsummaryrefslogtreecommitdiff
path: root/lib/std/multi_array_list.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2025-06-12 20:46:36 -0400
committerGitHub <noreply@github.com>2025-06-12 20:46:36 -0400
commitdcdb4422b801f2d184107fdd7b9493f7840a0244 (patch)
treeca7a37c544382c10e45fbad68ea7701a05d0543c /lib/std/multi_array_list.zig
parent5e3c0b7af7cd866f5464c244b9775e488b93ae48 (diff)
parent43d01ff69f6c6c46bef81dd4de2c78fb0a942b65 (diff)
downloadzig-dcdb4422b801f2d184107fdd7b9493f7840a0244.tar.gz
zig-dcdb4422b801f2d184107fdd7b9493f7840a0244.zip
Merge pull request #24124 from mlugg/better-backend-pipeline-2
compiler: threaded codegen (and more goodies)
Diffstat (limited to 'lib/std/multi_array_list.zig')
-rw-r--r--lib/std/multi_array_list.zig16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/std/multi_array_list.zig b/lib/std/multi_array_list.zig
index 341ca6931e..279a150799 100644
--- a/lib/std/multi_array_list.zig
+++ b/lib/std/multi_array_list.zig
@@ -135,6 +135,22 @@ pub fn MultiArrayList(comptime T: type) type {
self.* = undefined;
}
+ /// Returns a `Slice` representing a range of elements in `s`, analagous to `arr[off..len]`.
+ /// It is illegal to call `deinit` or `toMultiArrayList` on the returned `Slice`.
+ /// Asserts that `off + len <= s.len`.
+ pub fn subslice(s: Slice, off: usize, len: usize) Slice {
+ assert(off + len <= s.len);
+ var ptrs: [fields.len][*]u8 = undefined;
+ inline for (s.ptrs, &ptrs, fields) |in, *out, field| {
+ out.* = in + (off * @sizeOf(field.type));
+ }
+ return .{
+ .ptrs = ptrs,
+ .len = len,
+ .capacity = len,
+ };
+ }
+
/// This function is used in the debugger pretty formatters in tools/ to fetch the
/// child field order and entry type to facilitate fancy debug printing for this type.
fn dbHelper(self: *Slice, child: *Elem, field: *Field, entry: *Entry) void {