diff options
Diffstat (limited to 'src/bun.js/node')
-rw-r--r-- | src/bun.js/node/types.zig | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/bun.js/node/types.zig b/src/bun.js/node/types.zig index 79fdf9e6b..6c4ee9f51 100644 --- a/src/bun.js/node/types.zig +++ b/src/bun.js/node/types.zig @@ -626,6 +626,14 @@ pub const PathLike = union(Tag) { pub const Tag = enum { string, buffer, slice_with_underlying_string }; + pub fn estimatedSize(this: *const PathLike) usize { + return switch (this.*) { + .string => this.string.estimatedSize(), + .buffer => this.buffer.slice().len, + .slice_with_underlying_string => 0, + }; + } + pub fn deinit(this: *const PathLike) void { if (this.* == .slice_with_underlying_string) { this.slice_with_underlying_string.deinit(); @@ -1059,6 +1067,13 @@ pub const PathOrFileDescriptor = union(Tag) { } } + pub fn estimatedSize(this: *const PathOrFileDescriptor) usize { + return switch (this.*) { + .path => this.path.estimatedSize(), + .fd => 0, + }; + } + pub fn toThreadSafe(this: *PathOrFileDescriptor) void { if (this.* == .path) { this.path.toThreadSafe(); |