From e887a064fb63347b4a4b21c282c1db01dfee98b1 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Fri, 24 Feb 2023 15:53:26 +0200 Subject: prefer `bun.copy()` over `std.mem.copy()` (#2152) --- src/builder.zig | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 src/builder.zig (limited to 'src/builder.zig') diff --git a/src/builder.zig b/src/builder.zig deleted file mode 100644 index 10c81aaf8..000000000 --- a/src/builder.zig +++ /dev/null @@ -1,33 +0,0 @@ -const Allocator = @import("std").mem.Allocator; -const assert = @import("std").debug.assert; -const copy = @import("std").mem.copy; -const io = @import("bun").AsyncIO; -pub fn Builder(comptime Type: type) type { - return struct { - const This = @This(); - - len: usize = 0, - cap: usize = 0, - ptr: ?[*]Type = null, - - pub fn count(this: *This, slice: Type) void { - this.cap += slice.len; - } - - pub fn allocate(this: *This, allocator: Allocator) !void { - var slice = try allocator.alloc(Type, this.cap); - this.ptr = slice.ptr; - this.len = 0; - } - - pub fn append(this: *This, item: Type) *const Type { - assert(this.len <= this.cap); // didn't count everything - assert(this.ptr != null); // must call allocate first - var result = &this.ptr.?[this.len]; - result.* = item; - this.len += 1; - assert(this.len <= this.cap); - return result; - } - }; -} -- cgit v1.2.3