Skip to content

Commit fc044ac

Browse files
committed
ArrayList -> ArrayListManaged
1 parent 75fcadc commit fc044ac

13 files changed

Lines changed: 52 additions & 41 deletions

File tree

build.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const std = @import("std");
2-
2+
const ArrayListManaged = std.array_list.Managed;
33
pub fn build(b: *std.Build) !void {
44
const target = b.standardTargetOptions(.{});
55
const optimize = b.standardOptimizeOption(.{});
@@ -193,7 +193,7 @@ fn findFilesSorted(allocator: std.mem.Allocator, path: []const u8) ![][]const u8
193193
};
194194
defer dir.close();
195195

196-
var files = std.ArrayList([]const u8).init(allocator);
196+
var files = ArrayListManaged([]const u8).init(allocator);
197197

198198
var it = dir.iterate();
199199
while (try it.next()) |entry| {

build.zig.zon

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
.name = .jetquery,
33
.version = "0.0.0",
44
.fingerprint = 0x8fab0d79cef7d74c,
5-
.minimum_zig_version = "0.15.0-dev.1425+7ee6dab39",
5+
.minimum_zig_version = "0.15.1",
66
.dependencies = .{
77
.jetcommon = .{
8-
.url = "https://github.com/jetzig-framework/jetcommon/archive/ff1f2cf50e6d0b35bfdadc77f9d21cf2a3e05b26.tar.gz",
9-
.hash = "jetcommon-0.1.0-jPY_DdNIAAA7pPOLsOkd5BH4juCnM4F71sNLK2aiwMs6",
8+
.url = "https://github.com/jetzig-framework/jetcommon/archive/f613f2cb9084d4b1c19ea89f5dab9ad7ba4fa3c4.tar.gz",
9+
.hash = "jetcommon-0.1.0-jPY_DRRJAADaN4sQby3c31hyFSAgqIP90D4DYcTNVquG",
1010
},
1111
.pg = .{
12-
.url = "https://github.com/karlseguin/pg.zig/archive/6a164b282eb69bb033b05301aa839be3bfdb8dd8.tar.gz",
13-
.hash = "pg-0.0.0-Wp_7gWYABgDCWzy0PvaGuwpn1PxTqihfYowektiN11n7",
12+
.url = "https://github.com/karlseguin/pg.zig/archive/4c2602bad095f9d85b16711d12aa3a2bc7e169cc.tar.gz",
13+
.hash = "pg-0.0.0-Wp_7gQ8FBgCRArfpYn9OdkUhGOUHVRXxB6h9S6lYu7bC",
1414
},
1515
},
1616
.paths = .{

src/generate_migrations.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const std = @import("std");
2+
const ArrayListManaged = std.array_list.Managed;
23

34
pub fn main() !void {
45
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
@@ -58,7 +59,7 @@ pub fn main() !void {
5859
}
5960

6061
fn zigEscape(allocator: std.mem.Allocator, input: []const u8) ![]const u8 {
61-
var buf = std.ArrayList(u8).init(allocator);
62+
var buf = ArrayListManaged(u8).init(allocator);
6263
const writer = buf.writer();
6364
try std.zig.stringEscape(input, "", .{}, writer);
6465
return try buf.toOwnedSlice();

src/generate_seeders.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const std = @import("std");
2+
const ArrayListManaged = std.array_list.Managed;
23

34
pub fn main() !void {
45
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
@@ -54,7 +55,7 @@ pub fn main() !void {
5455
}
5556

5657
fn zigEscape(allocator: std.mem.Allocator, input: []const u8) ![]const u8 {
57-
var buf = std.ArrayList(u8).init(allocator);
58+
var buf = ArrayListManaged(u8).init(allocator);
5859
const writer = buf.writer();
5960
try std.zig.stringEscape(input, "", .{}, writer);
6061
return try buf.toOwnedSlice();

src/jetquery.zig

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const std = @import("std");
2+
const ArrayListManaged = std.array_list.Managed;
23

34
pub const jetcommon = @import("jetcommon");
45

@@ -1010,7 +1011,7 @@ test "slice of []const u8 in whereclause" {
10101011
.{},
10111012
);
10121013
};
1013-
var array = std.ArrayList([]const u8).init(std.testing.allocator);
1014+
var array = ArrayListManaged([]const u8).init(std.testing.allocator);
10141015
defer array.deinit();
10151016

10161017
try array.append("Bob");
@@ -1032,7 +1033,7 @@ test "slice of int in whereclause" {
10321033
.{},
10331034
);
10341035
};
1035-
var array = std.ArrayList(u128).init(std.testing.allocator);
1036+
var array = ArrayListManaged(u128).init(std.testing.allocator);
10361037
defer array.deinit();
10371038

10381039
try array.append(2);
@@ -1054,7 +1055,7 @@ test "slice of float in whereclause" {
10541055
.{},
10551056
);
10561057
};
1057-
var array = std.ArrayList(f64).init(std.testing.allocator);
1058+
var array = ArrayListManaged(f64).init(std.testing.allocator);
10581059
defer array.deinit();
10591060

10601061
try array.append(3.1415926535897932);
@@ -1076,7 +1077,7 @@ test "slice of bool in whereclause" {
10761077
.{},
10771078
);
10781079
};
1079-
var array = std.ArrayList(bool).init(std.testing.allocator);
1080+
var array = ArrayListManaged(bool).init(std.testing.allocator);
10801081
defer array.deinit();
10811082

10821083
try array.append(true);

src/jetquery/Migration.zig

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const std = @import("std");
2+
const ArrayListManaged = std.array_list.Managed;
23

34
const jetcommon = @import("jetcommon");
45

@@ -395,13 +396,13 @@ const Command = struct {
395396
var arg_iterator = std.mem.tokenizeAny(u8, self.command, &std.ascii.whitespace);
396397
var token_iterator = TokenIterator{ .arg_iterator = &arg_iterator };
397398

398-
var up_buf = std.ArrayList(u8).init(self.allocator);
399+
var up_buf = ArrayListManaged(u8).init(self.allocator);
399400
const up_writer = up_buf.writer();
400401

401-
var down_buf = std.ArrayList(u8).init(self.allocator);
402+
var down_buf = ArrayListManaged(u8).init(self.allocator);
402403
const down_writer = down_buf.writer();
403404

404-
var columns = std.ArrayList(Command.Token.Column).init(self.allocator);
405+
var columns = ArrayListManaged(Command.Token.Column).init(self.allocator);
405406
var maybe_table: ?Command.Token.Table = null;
406407

407408
while (try token_iterator.next()) |token| {
@@ -503,7 +504,7 @@ pub fn render(self: Migration) ![]const u8 {
503504
defer arena.deinit();
504505
const alloc = arena.allocator();
505506

506-
var buf = std.ArrayList(u8).init(alloc);
507+
var buf = ArrayListManaged(u8).init(alloc);
507508
const writer = buf.writer();
508509

509510
if (self.options.command) |cmd| {

src/jetquery/Repo.zig

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const std = @import("std");
2+
const ArrayListManaged = std.array_list.Managed;
23

34
const jetquery = @import("../jetquery.zig");
45

@@ -554,7 +555,7 @@ pub fn Repo(adapter_name: jetquery.adapters.Name, Schema: type) type {
554555
comptime columns: []const jetquery.schema.Column,
555556
comptime options: jetquery.CreateTableOptions,
556557
) !void {
557-
var buf = std.ArrayList(u8).init(self.allocator);
558+
var buf = ArrayListManaged(u8).init(self.allocator);
558559
defer buf.deinit();
559560

560561
const writer = buf.writer();
@@ -591,7 +592,7 @@ pub fn Repo(adapter_name: jetquery.adapters.Name, Schema: type) type {
591592
comptime name: []const u8,
592593
comptime options: jetquery.DropTableOptions,
593594
) !void {
594-
var buf = std.ArrayList(u8).init(self.allocator);
595+
var buf = ArrayListManaged(u8).init(self.allocator);
595596
defer buf.deinit();
596597

597598
const writer = buf.writer();
@@ -615,7 +616,7 @@ pub fn Repo(adapter_name: jetquery.adapters.Name, Schema: type) type {
615616
comptime name: []const u8,
616617
comptime options: jetquery.AlterTableOptions,
617618
) !void {
618-
var buf = std.ArrayList(u8).init(self.allocator);
619+
var buf = ArrayListManaged(u8).init(self.allocator);
619620
defer buf.deinit();
620621
const writer = buf.writer();
621622

@@ -672,7 +673,7 @@ pub fn Repo(adapter_name: jetquery.adapters.Name, Schema: type) type {
672673
options: struct {},
673674
) !void {
674675
_ = options;
675-
var buf = std.ArrayList(u8).init(self.allocator);
676+
var buf = ArrayListManaged(u8).init(self.allocator);
676677
defer buf.deinit();
677678
const database = try self.adapter.identifierAlloc(self.allocator, name);
678679
defer self.allocator.free(database);
@@ -699,7 +700,7 @@ pub fn Repo(adapter_name: jetquery.adapters.Name, Schema: type) type {
699700
name: []const u8,
700701
options: jetquery.DropDatabaseOptions,
701702
) !void {
702-
var buf = std.ArrayList(u8).init(self.allocator);
703+
var buf = ArrayListManaged(u8).init(self.allocator);
703704
defer buf.deinit();
704705
const database = try self.adapter.identifierAlloc(self.allocator, name);
705706
defer self.allocator.free(database);

src/jetquery/Result.zig

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const std = @import("std");
2+
const ArrayListManaged = std.array_list.Managed;
23

34
const jetquery = @import("../jetquery.zig");
45
const AuxiliaryQuery = @import("Query.zig").AuxiliaryQuery;
@@ -72,7 +73,7 @@ pub fn Result(AdaptedRepo: type) type {
7273

7374
const aux_type = AuxType(ResultType, aux_query.relation);
7475

75-
var aux_rows = std.ArrayList(aux_type).init(adapted_result.allocator);
76+
var aux_rows = ArrayListManaged(aux_type).init(adapted_result.allocator);
7677
while (try aux_result.next(q)) |aux_row| {
7778
try aux_rows.append(mergeAux(
7879
aux_type,
@@ -120,7 +121,7 @@ pub fn Result(AdaptedRepo: type) type {
120121
@field(
121122
merged_row,
122123
init_aux_query.relation.relation_name,
123-
) = std.ArrayList(aux_type).init(adapted_result.allocator);
124+
) = ArrayListManaged(aux_type).init(adapted_result.allocator);
124125
}
125126
const aux_values = try map.aux_map.getOrPut(index);
126127
aux_values.value_ptr.* = merged_row;
@@ -280,7 +281,7 @@ fn MergedRowType(auxiliary_queries: []const AuxiliaryQuery, ResultType: type) ty
280281
for (auxiliary_queries, 0..) |aux_query, index| {
281282
fields[index] = jetquery.fields.structField(
282283
aux_query.relation.relation_name,
283-
std.ArrayList(AuxType(ResultType, aux_query.relation)),
284+
ArrayListManaged(AuxType(ResultType, aux_query.relation)),
284285
);
285286
}
286287
return jetquery.fields.structType(&fields);
@@ -341,7 +342,7 @@ fn PrimaryKey(Query: type, comptime primary_key: []const u8) type {
341342

342343
fn Map(QueryType: type, MergedRow: type, comptime primary_key: []const u8) type {
343344
return struct {
344-
id_array: std.ArrayList(PrimaryKey(QueryType, primary_key)),
345+
id_array: ArrayListManaged(PrimaryKey(QueryType, primary_key)),
345346
id_map: IdMap(QueryType, primary_key),
346347
aux_map: std.AutoHashMap(usize, MergedRow),
347348

@@ -350,7 +351,7 @@ fn Map(QueryType: type, MergedRow: type, comptime primary_key: []const u8) type
350351
const IM = IdMap(QueryType, primary_key);
351352
const AM = std.AutoHashMap(usize, MergedRow);
352353
return .{
353-
.id_array = std.ArrayList(PK).init(allocator),
354+
.id_array = ArrayListManaged(PK).init(allocator),
354355
.id_map = IM.init(allocator),
355356
.aux_map = AM.init(allocator),
356357
};

src/jetquery/Seeder.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const std = @import("std");
2+
const ArrayListManaged = std.array_list.Managed;
23

34
const jetcommon = @import("jetcommon");
45

@@ -68,7 +69,7 @@ pub fn render(self: Seeder) ![]const u8 {
6869
defer arena.deinit();
6970
const alloc = arena.allocator();
7071

71-
var buf = std.ArrayList(u8).init(alloc);
72+
var buf = ArrayListManaged(u8).init(alloc);
7273
const writer = buf.writer();
7374
try writer.writeAll(seeder_template);
7475

src/jetquery/adapters/PostgresqlAdapter.zig

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const std = @import("std");
2+
const ArrayListManaged = std.array_list.Managed;
23
const builtin = @import("builtin");
34

45
const pg = @import("pg");
@@ -89,7 +90,7 @@ pub fn Result(AdaptedRepo: type) type {
8990
pub fn all(self: *Self, query: anytype) ![]@TypeOf(query).ResultType {
9091
defer self.deinit();
9192

92-
var array = std.ArrayList(@TypeOf(query).ResultType).init(self.allocator);
93+
var array = ArrayListManaged(@TypeOf(query).ResultType).init(self.allocator);
9394
while (try self.next(query)) |row| try array.append(row);
9495
return try array.toOwnedSlice();
9596
}
@@ -674,7 +675,7 @@ pub fn reflectTables(
674675
var result = try repo.executeSql(sql, .{});
675676
defer result.deinit();
676677

677-
var tables = std.ArrayList(jetquery.Reflection.TableInfo).init(allocator);
678+
var tables = ArrayListManaged(jetquery.Reflection.TableInfo).init(allocator);
678679
while (try result.postgresql.result.next()) |row| {
679680
try tables.append(.{
680681
.name = try allocator.dupe(u8, row.get([]const u8, 0)),
@@ -695,7 +696,7 @@ pub fn reflectColumns(
695696
var result = try repo.executeSql(sql, .{});
696697
defer result.deinit();
697698

698-
var columns = std.ArrayList(jetquery.Reflection.ColumnInfo).init(allocator);
699+
var columns = ArrayListManaged(jetquery.Reflection.ColumnInfo).init(allocator);
699700
while (try result.postgresql.result.next()) |row| {
700701
try columns.append(.{
701702
.table = try allocator.dupe(u8, row.get([]const u8, 0)),
@@ -714,7 +715,7 @@ fn reflectPrimaryKeys(
714715
allocator: std.mem.Allocator,
715716
repo: anytype,
716717
) ![]const jetquery.Reflection.PrimaryKeyInfo {
717-
var primary_keys = std.ArrayList(jetquery.Reflection.PrimaryKeyInfo).init(allocator);
718+
var primary_keys = ArrayListManaged(jetquery.Reflection.PrimaryKeyInfo).init(allocator);
718719

719720
var result = try repo.executeSql(
720721
\\select "pg_class"."relname",
@@ -745,7 +746,7 @@ fn reflectForeignKeys(
745746
allocator: std.mem.Allocator,
746747
repo: anytype,
747748
) ![]const jetquery.Reflection.ForeignKeyInfo {
748-
var foreign_keys = std.ArrayList(jetquery.Reflection.ForeignKeyInfo).init(allocator);
749+
var foreign_keys = ArrayListManaged(jetquery.Reflection.ForeignKeyInfo).init(allocator);
749750

750751
var result = try repo.executeSql(
751752
\\select "information_schema"."table_constraints"."table_name",

0 commit comments

Comments
 (0)