File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed
Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -101,7 +101,9 @@ pub fn Pool(comptime T: type) type {
101101 const old_slice = self .items ;
102102 const new_size = std .math .ceilPowerOfTwoAssert (usize , self .items .len + 1 );
103103
104- if (self .allocator .resize (self .items , new_size )) {
104+ if (self .allocator .remap (self .items , new_size )) | new_slice | {
105+ self .items = new_slice ;
106+ } else if (self .allocator .resize (self .items , new_size )) {
105107 self .items = self .items .ptr [0.. new_size ];
106108 } else {
107109 const new_slice = try self .allocator .alloc (T , new_size );
Original file line number Diff line number Diff line change @@ -54,7 +54,10 @@ pub fn ZeroCopy(comptime T: type) type {
5454 const old_slice = self .ptr [0.. self .capacity ];
5555 const new_size = try std .math .ceilPowerOfTwo (usize , self .capacity + size );
5656
57- if (self .allocator .resize (self .ptr [0.. self .capacity ], new_size )) {
57+ if (self .allocator .remap (self .ptr [0.. self .capacity ], new_size )) | new | {
58+ self .ptr = new .ptr ;
59+ self .capacity = new .len ;
60+ } else if (self .allocator .resize (self .ptr [0.. self .capacity ], new_size )) {
5861 self .capacity = new_size ;
5962 } else {
6063 const new_slice = try self .allocator .alloc (T , new_size );
You can’t perform that action at this time.
0 commit comments