From 2a9e967fd1c766a718808d5a7fa779d74d44e62c Mon Sep 17 00:00:00 2001 From: Ashcon Partovi Date: Sat, 26 Aug 2023 02:34:25 -0700 Subject: More improvements to debugger support (#4345) * More fixes for dap * More changes * More changes 2 * More fixes * Fix debugger.ts * Bun Terminal --- src/bun.js/node/types.zig | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/bun.js/node') 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(); -- cgit v1.2.3