Merge pull request #1471 from lightpanda-io/arraylistunmanaged_to_arraylist

Rename all ArrayListUnmanaged -> ArrayList
This commit is contained in:
Karl Seguin
2026-02-05 15:49:06 +08:00
committed by GitHub
20 changed files with 39 additions and 40 deletions

View File

@@ -724,7 +724,7 @@ fn parseCommonArg(
return true; return true;
}; };
var arr: std.ArrayListUnmanaged(log.Scope) = .empty; var arr: std.ArrayList(log.Scope) = .empty;
var it = std.mem.splitScalar(u8, str, ','); var it = std.mem.splitScalar(u8, str, ',');
while (it.next()) |part| { while (it.next()) |part| {

View File

@@ -61,7 +61,7 @@ event_listeners: EventListeners,
// list of listeners for a specified receiver // list of listeners for a specified receiver
// @intFromPtr(receiver) -> [listener1, listener2, ...] // @intFromPtr(receiver) -> [listener1, listener2, ...]
// Used when `unregisterAll` is called. // Used when `unregisterAll` is called.
listeners: std.AutoHashMapUnmanaged(usize, std.ArrayListUnmanaged(*Listener)), listeners: std.AutoHashMapUnmanaged(usize, std.ArrayList(*Listener)),
allocator: Allocator, allocator: Allocator,
mem_pool: std.heap.MemoryPool(Listener), mem_pool: std.heap.MemoryPool(Listener),

View File

@@ -561,7 +561,7 @@ pub const Client = struct {
pub fn sendJSONRaw( pub fn sendJSONRaw(
self: *Client, self: *Client,
buf: std.ArrayListUnmanaged(u8), buf: std.ArrayList(u8),
) !void { ) !void {
// Dangerous API!. We assume the caller has reserved the first 10 // Dangerous API!. We assume the caller has reserved the first 10
// bytes in `buf`. // bytes in `buf`.
@@ -883,7 +883,7 @@ fn growBuffer(allocator: Allocator, buf: []u8, required_capacity: usize) ![]u8 {
const Fragments = struct { const Fragments = struct {
type: Message.Type, type: Message.Type,
message: std.ArrayListUnmanaged(u8), message: std.ArrayList(u8),
}; };
const Message = struct { const Message = struct {
@@ -907,7 +907,7 @@ const OpCode = enum(u8) {
pong = 128 | 10, pong = 128 | 10,
}; };
fn fillWebsocketHeader(buf: std.ArrayListUnmanaged(u8)) []const u8 { fn fillWebsocketHeader(buf: std.ArrayList(u8)) []const u8 {
// can't use buf[0..10] here, because the header length // can't use buf[0..10] here, because the header length
// is variable. If it's just 2 bytes, for example, we need the // is variable. If it's just 2 bytes, for example, we need the
// framed message to be: // framed message to be:
@@ -1342,7 +1342,7 @@ fn assertWebSocketMessage(expected: []const u8, input: []const u8) !void {
} }
const MockCDP = struct { const MockCDP = struct {
messages: std.ArrayListUnmanaged([]const u8) = .{}, messages: std.ArrayList([]const u8) = .{},
allocator: Allocator = testing.allocator, allocator: Allocator = testing.allocator,

View File

@@ -757,7 +757,7 @@ fn pageDataCallback(transfer: *Http.Transfer, data: []const u8) !void {
switch (mime.content_type) { switch (mime.content_type) {
.text_html => self._parse_state = .{ .html = .{} }, .text_html => self._parse_state = .{ .html = .{} },
.application_json, .text_javascript, .text_css, .text_plain => { .application_json, .text_javascript, .text_css, .text_plain => {
var arr: std.ArrayListUnmanaged(u8) = .empty; var arr: std.ArrayList(u8) = .empty;
try arr.appendSlice(self.arena, "<html><head><meta charset=\"utf-8\"></head><body><pre>"); try arr.appendSlice(self.arena, "<html><head><meta charset=\"utf-8\"></head><body><pre>");
self._parse_state = .{ .text = arr }; self._parse_state = .{ .text = arr };
}, },
@@ -2866,9 +2866,9 @@ const ParseState = union(enum) {
pre, pre,
complete, complete,
err: anyerror, err: anyerror,
html: std.ArrayListUnmanaged(u8), html: std.ArrayList(u8),
text: std.ArrayListUnmanaged(u8), text: std.ArrayList(u8),
raw: std.ArrayListUnmanaged(u8), raw: std.ArrayList(u8),
raw_done: []const u8, raw_done: []const u8,
}; };

View File

@@ -31,7 +31,7 @@ const Http = @import("../http/Http.zig");
const Element = @import("webapi/Element.zig"); const Element = @import("webapi/Element.zig");
const Allocator = std.mem.Allocator; const Allocator = std.mem.Allocator;
const ArrayListUnmanaged = std.ArrayListUnmanaged; const ArrayList = std.ArrayList;
const IS_DEBUG = builtin.mode == .Debug; const IS_DEBUG = builtin.mode == .Debug;
@@ -634,7 +634,7 @@ pub const Script = struct {
const Source = union(enum) { const Source = union(enum) {
@"inline": []const u8, @"inline": []const u8,
remote: std.ArrayListUnmanaged(u8), remote: std.ArrayList(u8),
fn content(self: Source) []const u8 { fn content(self: Source) []const u8 {
return switch (self) { return switch (self) {
@@ -900,7 +900,7 @@ const BufferPool = struct {
const Container = struct { const Container = struct {
node: List.Node, node: List.Node,
buf: std.ArrayListUnmanaged(u8), buf: std.ArrayList(u8),
}; };
fn init(allocator: Allocator, max_concurrent_transfers: u8) BufferPool { fn init(allocator: Allocator, max_concurrent_transfers: u8) BufferPool {
@@ -925,7 +925,7 @@ const BufferPool = struct {
self.mem_pool.deinit(); self.mem_pool.deinit();
} }
fn get(self: *BufferPool) std.ArrayListUnmanaged(u8) { fn get(self: *BufferPool) std.ArrayList(u8) {
const node = self.available.popFirst() orelse { const node = self.available.popFirst() orelse {
// return a new buffer // return a new buffer
return .{}; return .{};
@@ -937,7 +937,7 @@ const BufferPool = struct {
return container.buf; return container.buf;
} }
fn release(self: *BufferPool, buffer: ArrayListUnmanaged(u8)) void { fn release(self: *BufferPool, buffer: ArrayList(u8)) void {
// create mutable copy // create mutable copy
var b = buffer; var b = buffer;

View File

@@ -903,9 +903,9 @@ pub fn enter(self: *Context, hs: *js.HandleScope) Entered {
const original = page.js; const original = page.js;
page.js = self; page.js = self;
const handle: *const v8.Context = @ptrCast(v8.v8__Global__Get(&self.handle, isolate.handle)); const handle: *const v8.Context = @ptrCast(v8.v8__Global__Get(&self.handle, isolate.handle));
v8.v8__Context__Enter(handle); v8.v8__Context__Enter(handle);
return .{.original = original, .handle = handle, .handle_scope = hs}; return .{ .original = original, .handle = handle, .handle_scope = hs };
} }
const Entered = struct { const Entered = struct {

View File

@@ -74,7 +74,6 @@ pub fn add(self: *Scheduler, ctx: *anyopaque, cb: Callback, run_in_ms: u32, opts
}); });
} }
pub fn run(self: *Scheduler) !?u64 { pub fn run(self: *Scheduler) !?u64 {
_ = try self.runQueue(&self.low_priority); _ = try self.runQueue(&self.low_priority);
return self.runQueue(&self.high_priority); return self.runQueue(&self.high_priority);

View File

@@ -46,7 +46,7 @@ pub const Entry = struct {
pub const KeyValueList = @This(); pub const KeyValueList = @This();
_entries: std.ArrayListUnmanaged(Entry) = .empty, _entries: std.ArrayList(Entry) = .empty,
pub const empty: KeyValueList = .{ pub const empty: KeyValueList = .{
._entries = .empty, ._entries = .empty,

View File

@@ -667,7 +667,7 @@ pub fn setData(self: *Node, data: []const u8, page: *Page) !void {
} }
pub fn normalize(self: *Node, page: *Page) !void { pub fn normalize(self: *Node, page: *Page) !void {
var buffer: std.ArrayListUnmanaged(u8) = .empty; var buffer: std.ArrayList(u8) = .empty;
return self._normalize(page.call_arena, &buffer, page); return self._normalize(page.call_arena, &buffer, page);
} }
@@ -797,7 +797,7 @@ fn isNodeBefore(node1: *const Node, node2: *const Node) bool {
return false; return false;
} }
fn _normalize(self: *Node, allocator: Allocator, buffer: *std.ArrayListUnmanaged(u8), page: *Page) !void { fn _normalize(self: *Node, allocator: Allocator, buffer: *std.ArrayList(u8), page: *Page) !void {
var it = self.childrenIterator(); var it = self.childrenIterator();
while (it.next()) |child| { while (it.next()) |child| {
try child._normalize(allocator, buffer, page); try child._normalize(allocator, buffer, page);

View File

@@ -28,7 +28,7 @@ _fatal: bool,
_page: *Page, _page: *Page,
_arena: Allocator, _arena: Allocator,
_ignore_bom: bool, _ignore_bom: bool,
_stream: std.ArrayListUnmanaged(u8), _stream: std.ArrayList(u8),
const Label = enum { const Label = enum {
utf8, utf8,

View File

@@ -379,7 +379,7 @@ pub fn appliesTo(self: *const Cookie, url: *const PreparedUri, same_site: bool,
pub const Jar = struct { pub const Jar = struct {
allocator: Allocator, allocator: Allocator,
cookies: std.ArrayListUnmanaged(Cookie), cookies: std.ArrayList(Cookie),
pub fn init(allocator: Allocator) Jar { pub fn init(allocator: Allocator) Jar {
return .{ return .{
@@ -635,7 +635,7 @@ test "Jar: add" {
test "Jar: forRequest" { test "Jar: forRequest" {
const expectCookies = struct { const expectCookies = struct {
fn expect(expected: []const u8, jar: *Jar, target_url: [:0]const u8, opts: Jar.LookupOpts) !void { fn expect(expected: []const u8, jar: *Jar, target_url: [:0]const u8, opts: Jar.LookupOpts) !void {
var arr: std.ArrayListUnmanaged(u8) = .empty; var arr: std.ArrayList(u8) = .empty;
defer arr.deinit(testing.allocator); defer arr.deinit(testing.allocator);
try jar.forRequest(target_url, arr.writer(testing.allocator), opts); try jar.forRequest(target_url, arr.writer(testing.allocator), opts);
try testing.expectEqual(expected, arr.items); try testing.expectEqual(expected, arr.items);

View File

@@ -123,7 +123,7 @@ pub const Search = struct {
search_id: u16 = 0, search_id: u16 = 0,
registry: *Registry, registry: *Registry,
arena: std.heap.ArenaAllocator, arena: std.heap.ArenaAllocator,
searches: std.ArrayListUnmanaged(Search) = .{}, searches: std.ArrayList(Search) = .{},
pub fn init(allocator: Allocator, registry: *Registry) List { pub fn init(allocator: Allocator, registry: *Registry) List {
return .{ return .{

View File

@@ -120,7 +120,7 @@ fn insertText(cmd: anytype) !void {
fn clickNavigate(cmd: anytype, uri: std.Uri) !void { fn clickNavigate(cmd: anytype, uri: std.Uri) !void {
const bc = cmd.browser_context.?; const bc = cmd.browser_context.?;
var url_buf: std.ArrayListUnmanaged(u8) = .{}; var url_buf: std.ArrayList(u8) = .{};
try uri.writeToStream(.{ try uri.writeToStream(.{
.scheme = true, .scheme = true,
.authentication = true, .authentication = true,

View File

@@ -178,7 +178,7 @@ fn getCookies(cmd: anytype) !void {
const page_url = if (bc.session.page) |page| page.url else null; const page_url = if (bc.session.page) |page| page.url else null;
const param_urls = params.urls orelse &[_][:0]const u8{page_url orelse return error.InvalidParams}; const param_urls = params.urls orelse &[_][:0]const u8{page_url orelse return error.InvalidParams};
var urls = try std.ArrayListUnmanaged(CdpStorage.PreparedUri).initCapacity(cmd.arena, param_urls.len); var urls = try std.ArrayList(CdpStorage.PreparedUri).initCapacity(cmd.arena, param_urls.len);
for (param_urls) |url| { for (param_urls) |url| {
urls.appendAssumeCapacity(.{ urls.appendAssumeCapacity(.{
.host = try Cookie.parseDomain(cmd.arena, url, null), .host = try Cookie.parseDomain(cmd.arena, url, null),

View File

@@ -38,8 +38,8 @@ pub const newString = base.newString;
const Client = struct { const Client = struct {
allocator: Allocator, allocator: Allocator,
send_arena: ArenaAllocator, send_arena: ArenaAllocator,
sent: std.ArrayListUnmanaged(json.Value) = .{}, sent: std.ArrayList(json.Value) = .{},
serialized: std.ArrayListUnmanaged([]const u8) = .{}, serialized: std.ArrayList([]const u8) = .{},
fn init(alloc: Allocator) Client { fn init(alloc: Allocator) Client {
return .{ return .{
@@ -58,7 +58,7 @@ const Client = struct {
try self.sent.append(self.allocator, value); try self.sent.append(self.allocator, value);
} }
pub fn sendJSONRaw(self: *Client, buf: std.ArrayListUnmanaged(u8)) !void { pub fn sendJSONRaw(self: *Client, buf: std.ArrayList(u8)) !void {
const value = try json.parseFromSliceLeaky(json.Value, self.allocator, buf.items, .{}); const value = try json.parseFromSliceLeaky(json.Value, self.allocator, buf.items, .{});
try self.sent.append(self.allocator, value); try self.sent.append(self.allocator, value);
} }

View File

@@ -565,7 +565,7 @@ fn processMessages(self: *Client) !bool {
// In case of auth challenge // In case of auth challenge
// TODO give a way to configure the number of auth retries. // TODO give a way to configure the number of auth retries.
if (transfer._auth_challenge != null and transfer._tries < 10) { if (transfer._auth_challenge != null and transfer._tries < 10) {
var wait_for_interception = false; var wait_for_interception = false;
transfer.req.notification.dispatch(.http_request_auth_required, &.{ .transfer = transfer, .wait_for_interception = &wait_for_interception }); transfer.req.notification.dispatch(.http_request_auth_required, &.{ .transfer = transfer, .wait_for_interception = &wait_for_interception });
if (wait_for_interception) { if (wait_for_interception) {
@@ -764,7 +764,7 @@ pub const RequestCookie = struct {
origin: [:0]const u8, origin: [:0]const u8,
pub fn headersForRequest(self: *const RequestCookie, temp: Allocator, url: [:0]const u8, headers: *Http.Headers) !void { pub fn headersForRequest(self: *const RequestCookie, temp: Allocator, url: [:0]const u8, headers: *Http.Headers) !void {
var arr: std.ArrayListUnmanaged(u8) = .{}; var arr: std.ArrayList(u8) = .{};
try self.jar.forRequest(url, arr.writer(temp), .{ try self.jar.forRequest(url, arr.writer(temp), .{
.is_http = self.is_http, .is_http = self.is_http,
.is_navigation = self.is_navigation, .is_navigation = self.is_navigation,
@@ -992,7 +992,7 @@ pub const Transfer = struct {
pub fn replaceRequestHeaders(self: *Transfer, allocator: Allocator, headers: []const Http.Header) !void { pub fn replaceRequestHeaders(self: *Transfer, allocator: Allocator, headers: []const Http.Header) !void {
self.req.headers.deinit(); self.req.headers.deinit();
var buf: std.ArrayListUnmanaged(u8) = .empty; var buf: std.ArrayList(u8) = .empty;
var new_headers = try self.client.newHeaders(); var new_headers = try self.client.newHeaders();
for (headers) |hdr| { for (headers) |hdr| {
// safe to re-use this buffer, because Headers.add because curl copies // safe to re-use this buffer, because Headers.add because curl copies
@@ -1077,7 +1077,7 @@ pub const Transfer = struct {
const url = try URL.resolve(arena, std.mem.span(base_url), location.value, .{}); const url = try URL.resolve(arena, std.mem.span(base_url), location.value, .{});
transfer.url = url; transfer.url = url;
var cookies: std.ArrayListUnmanaged(u8) = .{}; var cookies: std.ArrayList(u8) = .{};
try req.cookie_jar.forRequest(url, cookies.writer(arena), .{ try req.cookie_jar.forRequest(url, cookies.writer(arena), .{
.is_http = true, .is_http = true,
.origin_url = url, .origin_url = url,

View File

@@ -364,7 +364,7 @@ fn loadCerts(allocator: Allocator, arena: Allocator) !c.curl_blob {
} }
const encoder = std.base64.standard.Encoder; const encoder = std.base64.standard.Encoder;
var arr: std.ArrayListUnmanaged(u8) = .empty; var arr: std.ArrayList(u8) = .empty;
const encoded_size = encoder.calcSize(bytes.len); const encoded_size = encoder.calcSize(bytes.len);
const buffer_size = encoded_size + const buffer_size = encoded_size +
@@ -399,7 +399,7 @@ fn loadCerts(allocator: Allocator, arena: Allocator) !c.curl_blob {
// and footer // and footer
const LineWriter = struct { const LineWriter = struct {
col: usize = 0, col: usize = 0,
inner: std.ArrayListUnmanaged(u8).Writer, inner: std.ArrayList(u8).Writer,
pub fn writeAll(self: *LineWriter, data: []const u8) !void { pub fn writeAll(self: *LineWriter, data: []const u8) !void {
var writer = self.inner; var writer = self.inner;

View File

@@ -158,7 +158,7 @@ const Writer = struct {
case_pass_count: usize = 0, case_pass_count: usize = 0,
case_fail_count: usize = 0, case_fail_count: usize = 0,
writer: std.fs.File.Writer, writer: std.fs.File.Writer,
cases: std.ArrayListUnmanaged(Case) = .{}, cases: std.ArrayList(Case) = .{},
const Format = enum { json, text, summary, quiet }; const Format = enum { json, text, summary, quiet };
@@ -337,7 +337,7 @@ fn parseArgs(arena: Allocator) !Command {
const exec_name = args.next().?; const exec_name = args.next().?;
var format = Writer.Format.text; var format = Writer.Format.text;
var filters: std.ArrayListUnmanaged([]const u8) = .{}; var filters: std.ArrayList([]const u8) = .{};
while (args.next()) |arg| { while (args.next()) |arg| {
if (std.mem.eql(u8, "-h", arg) or std.mem.eql(u8, "--help", arg)) { if (std.mem.eql(u8, "-h", arg) or std.mem.eql(u8, "--help", arg)) {

View File

@@ -182,7 +182,7 @@ const MockProvider = struct {
iid: ?[]const u8, iid: ?[]const u8,
run_mode: ?Config.RunMode, run_mode: ?Config.RunMode,
allocator: Allocator, allocator: Allocator,
events: std.ArrayListUnmanaged(Event), events: std.ArrayList(Event),
fn init(app: *App) !@This() { fn init(app: *App) !@This() {
return .{ return .{

View File

@@ -57,7 +57,7 @@ const Runner = struct {
// per-test arena, used for collecting substests // per-test arena, used for collecting substests
arena: Allocator, arena: Allocator,
subtests: std.ArrayListUnmanaged([]const u8), subtests: std.ArrayList([]const u8),
fn init(allocator: Allocator, arena: Allocator, ta: *TrackingAllocator, env: Env) Runner { fn init(allocator: Allocator, arena: Allocator, ta: *TrackingAllocator, env: Env) Runner {
return .{ return .{