Remove direct use of UnpinnedArray in Compilation

This commit is contained in:
David Gonzalez Martin 2024-04-25 22:07:40 -06:00
parent 104f8ef827
commit 3ee62420a3
3 changed files with 251 additions and 237 deletions

File diff suppressed because it is too large Load Diff

View File

@ -218,6 +218,16 @@ pub fn PinnedArray(comptime T: type) type {
array.length += count;
@memcpy(array.pointer[index..][0..count], items);
}
pub fn insert(array: *@This(), index: u32, item: T) void {
assert(index < array.length);
array.ensure_capacity(1);
const src = array.slice()[index..];
array.length += 1;
const dst = array.slice()[index + 1..];
copy_backwards(T, dst, src);
array.slice()[index] = item;
}
};
}

View File

@ -33,7 +33,7 @@ pub fn main() !void {
// assert(arguments.len > 0);
// const home_dir = std.posix.getenv("HOME") orelse unreachable;
// const timestamp = std.time.milliTimestamp();
// var argument_list = UnpinnedArray(u8){};
// var argument_list = PinnedArray(u8){};
// for (arguments) |arg| {
// argument_list.append_slice(context.my_allocator, arg) catch {};
// argument_list.append(context.my_allocator, ' ') catch {};