mirror of
https://github.com/oven-sh/bun
synced 2026-02-16 22:01:47 +00:00
Make cold bun install use 2x less memory (#3271)
* Make cold `bun install` use 2x less memory In this benchmark: https://github.com/orogene/orogene/blob/main/BENCHMARKS.md This brings us from around 2.7 GB to 1.2 GB of memory * Address comments --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
This commit is contained in:
@@ -235,6 +235,13 @@ pub const MutableString = struct {
|
||||
return self.list.items;
|
||||
}
|
||||
|
||||
/// Clear the existing value without freeing the memory or shrinking the capacity.
|
||||
pub fn move(self: *MutableString) []u8 {
|
||||
const out = self.list.items;
|
||||
self.list = .{};
|
||||
return out;
|
||||
}
|
||||
|
||||
pub fn toOwnedSentinelLeaky(self: *MutableString) [:0]u8 {
|
||||
if (self.list.items.len > 0 and self.list.items[self.list.items.len - 1] != 0) {
|
||||
self.list.append(
|
||||
|
||||
Reference in New Issue
Block a user