diff options
author | 2023-02-24 15:53:26 +0200 | |
---|---|---|
committer | 2023-02-24 05:53:26 -0800 | |
commit | e887a064fb63347b4a4b21c282c1db01dfee98b1 (patch) | |
tree | 6270a7ce5527ea06d709d4b92e14623518e0f5b5 /src/string_joiner.zig | |
parent | 6e4908e51793d82d3b6924b2ede9a02f1e95bf37 (diff) | |
download | bun-e887a064fb63347b4a4b21c282c1db01dfee98b1.tar.gz bun-e887a064fb63347b4a4b21c282c1db01dfee98b1.tar.zst bun-e887a064fb63347b4a4b21c282c1db01dfee98b1.zip |
prefer `bun.copy()` over `std.mem.copy()` (#2152)
Diffstat (limited to 'src/string_joiner.zig')
-rw-r--r-- | src/string_joiner.zig | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/string_joiner.zig b/src/string_joiner.zig index d6440008a..490989c9a 100644 --- a/src/string_joiner.zig +++ b/src/string_joiner.zig @@ -1,19 +1,15 @@ /// Rope-like data structure for joining many small strings into one big string. -const Joiner = @This(); - +const std = @import("std"); +const default_allocator = @import("bun").default_allocator; const string = @import("string_types.zig").string; -const Allocator = @import("std").mem.Allocator; -const assert = @import("std").debug.assert; -const copy = @import("std").mem.copy; -const Env = @import("./env.zig"); +const Allocator = std.mem.Allocator; const ObjectPool = @import("./pool.zig").ObjectPool; - -const default_allocator = @import("bun").default_allocator; +const Joiner = @This(); const Joinable = struct { offset: u31 = 0, needs_deinit: bool = false, - allocator: std.mem.Allocator = undefined, + allocator: Allocator = undefined, slice: []const u8 = "", pub const Pool = ObjectPool(Joinable, null, true, 4); @@ -22,12 +18,12 @@ const Joinable = struct { last_byte: u8 = 0, len: usize = 0, use_pool: bool = true, -node_allocator: std.mem.Allocator = undefined, +node_allocator: Allocator = undefined, head: ?*Joinable.Pool.Node = null, tail: ?*Joinable.Pool.Node = null, -pub fn done(this: *Joiner, allocator: std.mem.Allocator) ![]u8 { +pub fn done(this: *Joiner, allocator: Allocator) ![]u8 { if (this.head == null) { var out: []u8 = &[_]u8{}; return out; @@ -64,7 +60,7 @@ pub fn lastByte(this: *const Joiner) u8 { return 0; } -pub fn append(this: *Joiner, slice: string, offset: u32, allocator: ?std.mem.Allocator) void { +pub fn append(this: *Joiner, slice: string, offset: u32, allocator: ?Allocator) void { const data = slice[offset..]; this.len += @truncate(u32, data.len); @@ -91,5 +87,3 @@ pub fn append(this: *Joiner, slice: string, offset: u32, allocator: ?std.mem.All tail.next = new_tail; this.tail = new_tail; } - -const std = @import("std"); |