Compare commits

...

1 Commits

Author SHA1 Message Date
Jarred Sumner
bb7776116d https://github.com/ziglang/zig/issues/18949 2025-01-30 07:11:03 -08:00
13 changed files with 25 additions and 19 deletions

View File

@@ -5,7 +5,7 @@ pub const max_count = 128;
pub const Event = WatchEvent;
pub const Item = WatchItem;
pub const ItemList = WatchList;
pub const WatchList = std.MultiArrayList(WatchItem);
pub const WatchList = bun.MultiArrayList(WatchItem);
pub const HashType = u32;
const no_watch_item: WatchItemIndex = std.math.maxInt(WatchItemIndex);

View File

@@ -52,7 +52,13 @@ pub fn BabyList(comptime Type: type) type {
pub fn shrinkAndFree(this: *@This(), allocator: std.mem.Allocator, size: usize) void {
var list_ = this.listManaged(allocator);
const new_len = @min(size, @as(usize, list_.items.len));
// Workaround terrible zig std.ArrayList shrinkAndFree() behavior
list_.items.len = list_.capacity;
list_.shrinkAndFree(size);
list_.items.len = new_len;
this.update(list_);
}

View File

@@ -250,7 +250,7 @@ pub const TestRunner = struct {
log: logger.Log = logger.Log.initComptime(default_allocator),
module_scope: *DescribeScope = undefined,
pub const List = std.MultiArrayList(File);
pub const List = bun.MultiArrayList(File);
pub const ID = u32;
pub const Map = std.ArrayHashMapUnmanaged(u32, u32, ArrayIdentityContext, false);
};
@@ -259,7 +259,7 @@ pub const TestRunner = struct {
status: Status = Status.pending,
pub const ID = u32;
pub const List = std.MultiArrayList(Test);
pub const List = bun.MultiArrayList(Test);
pub const Status = enum(u3) {
pending,

View File

@@ -10269,7 +10269,7 @@ pub const LinkerContext = struct {
// Concatenate the generated CSS chunks together
const compile_results = chunk.compile_results_for_chunk;
var compile_results_for_source_map: std.MultiArrayList(CompileResultForSourceMap) = .{};
var compile_results_for_source_map: bun.MultiArrayList(CompileResultForSourceMap) = .{};
compile_results_for_source_map.setCapacity(worker.allocator, compile_results.len) catch bun.outOfMemory();
const sources: []const Logger.Source = c.parse_graph.input_files.items(.source);
@@ -10558,7 +10558,7 @@ pub const LinkerContext = struct {
// Concatenate the generated JavaScript chunks together
var prev_filename_comment: Index.Int = 0;
var compile_results_for_source_map: std.MultiArrayList(CompileResultForSourceMap) = .{};
var compile_results_for_source_map: bun.MultiArrayList(CompileResultForSourceMap) = .{};
compile_results_for_source_map.setCapacity(worker.allocator, compile_results.len) catch bun.outOfMemory();
const show_comments = c.options.mode == .bundle and
@@ -10773,7 +10773,7 @@ pub const LinkerContext = struct {
c: *LinkerContext,
isolated_hash: u64,
worker: *ThreadPool.Worker,
results: std.MultiArrayList(CompileResultForSourceMap),
results: bun.MultiArrayList(CompileResultForSourceMap),
chunk_abs_dir: string,
can_have_shifts: bool,
) !sourcemap.SourceMapPieces {

View File

@@ -8654,7 +8654,7 @@ pub const ServerComponentBoundary = struct {
/// speed, but also being able to pull a `[]const Index.Int` of all
/// boundaries for iteration.
pub const List = struct {
list: std.MultiArrayList(ServerComponentBoundary) = .{},
list: bun.MultiArrayList(ServerComponentBoundary) = .{},
/// Used to facilitate fast lookups into `items` by `.source_index`
map: Map = .{},
@@ -8698,7 +8698,7 @@ pub const ServerComponentBoundary = struct {
}
pub const Slice = struct {
list: std.MultiArrayList(ServerComponentBoundary).Slice,
list: bun.MultiArrayList(ServerComponentBoundary).Slice,
map: Map,
pub fn getIndex(l: *const Slice, real_source_index: Index.Int) ?usize {
@@ -8727,7 +8727,7 @@ pub const ServerComponentBoundary = struct {
};
pub const Adapter = struct {
list: std.MultiArrayList(ServerComponentBoundary).Slice,
list: bun.MultiArrayList(ServerComponentBoundary).Slice,
pub fn hash(_: Adapter, key: Index.Int) u32 {
return std.hash.uint32(key);

View File

@@ -1931,7 +1931,7 @@ pub const Env = struct {
key: string,
value: string,
};
const List = std.MultiArrayList(Entry);
const List = bun.MultiArrayList(Entry);
behavior: Api.DotEnvBehavior = Api.DotEnvBehavior.disable,
prefix: string = "",

View File

@@ -1204,7 +1204,7 @@ pub const ExportsMap = struct {
pub const Map = struct {
// This is not a std.ArrayHashMap because we also store the key_range which is a little weird
pub const List = std.MultiArrayList(MapEntry);
pub const List = bun.MultiArrayList(MapEntry);
expansion_keys: []MapEntry,
list: List,

View File

@@ -399,7 +399,7 @@ pub const PendingResolution = struct {
string_buf: []u8 = "",
tag: Tag,
pub const List = std.MultiArrayList(PendingResolution);
pub const List = bun.MultiArrayList(PendingResolution);
pub fn deinitListItems(list_: List, allocator: std.mem.Allocator) void {
var list = list_;

View File

@@ -35,7 +35,7 @@ pub const Param = struct {
name: string,
value: string,
pub const List = std.MultiArrayList(Param);
pub const List = bun.MultiArrayList(Param);
};
dir: StoredFileDescriptorType = .zero,
@@ -102,7 +102,7 @@ const RouteIndex = struct {
public_path: string,
hash: u32,
pub const List = std.MultiArrayList(RouteIndex);
pub const List = bun.MultiArrayList(RouteIndex);
};
pub const Routes = struct {
@@ -1553,7 +1553,7 @@ test "Pattern Match" {
const TestList = struct {
pub fn run(comptime list: anytype) usize {
const ParamListType = std.MultiArrayList(Entry);
const ParamListType = bun.MultiArrayList(Entry);
var parameters = ParamListType{};
var failures: usize = 0;
inline for (comptime std.meta.fieldNames(@TypeOf(list))) |pattern| {

View File

@@ -1324,7 +1324,7 @@ pub const LineOffsetTable = struct {
byte_offset_to_first_non_ascii: u32 = 0,
byte_offset_to_start_of_line: u32 = 0,
pub const List = std.MultiArrayList(LineOffsetTable);
pub const List = bun.MultiArrayList(LineOffsetTable);
pub fn findLine(byte_offsets_to_start_of_line: []const u32, loc: Logger.Loc) i32 {
assert(loc.start > -1); // checked by caller

View File

@@ -264,7 +264,7 @@ pub const MutableString = struct {
}
pub fn toOwnedSliceLength(self: *MutableString, length: usize) string {
self.list.shrinkAndFree(self.allocator, length);
self.list.items.len = @min(length, self.list.items.len);
return self.list.toOwnedSlice(self.allocator) catch bun.outOfMemory(); // TODO
}

View File

@@ -598,7 +598,7 @@ pub const QueryStringMap = struct {
name_hash: u64,
value: Api.StringPointer,
pub const List = std.MultiArrayList(Param);
pub const List = bun.MultiArrayList(Param);
};
pub fn initWithScanner(

View File

@@ -5,7 +5,7 @@ pub const max_count = 128;
pub const Event = WatchEvent;
pub const Item = WatchItem;
pub const ItemList = WatchList;
pub const WatchList = std.MultiArrayList(WatchItem);
pub const WatchList = bun.MultiArrayList(WatchItem);
pub const HashType = u32;
const no_watch_item: WatchItemIndex = std.math.maxInt(WatchItemIndex);