| author | |
| committer | |
| log | 0b9fccf508dc85fa522947d1cf6ff84f78f2dcb4 |
| tree | 7371629835c5ee935b33515395f7ad7fbd64c897 |
| parent | 6e3e23a941c6c82550c41771a223afeec4accd47 |
| signature |
In favour of newly-added decls, which can be used via decl literals.4 files changed, 36 insertions(+), 0 deletions(-)
lib/std/array_hash_map.zig+8| ... | @@ -510,6 +510,8 @@ pub fn ArrayHashMap( | ... | @@ -510,6 +510,8 @@ pub fn ArrayHashMap( |
| 510 | /// `store_hash` is `false` and the number of entries in the map is less than 9, | 510 | /// `store_hash` is `false` and the number of entries in the map is less than 9, |
| 511 | /// the overhead cost of using `ArrayHashMapUnmanaged` rather than `std.ArrayList` is | 511 | /// the overhead cost of using `ArrayHashMapUnmanaged` rather than `std.ArrayList` is |
| 512 | /// only a single pointer-sized integer. | 512 | /// only a single pointer-sized integer. |
| 513 | /// | ||
| 514 | /// Default initialization of this struct is deprecated; use `.empty` instead. | ||
| 513 | pub fn ArrayHashMapUnmanaged( | 515 | pub fn ArrayHashMapUnmanaged( |
| 514 | comptime K: type, | 516 | comptime K: type, |
| 515 | comptime V: type, | 517 | comptime V: type, |
| ... | @@ -538,6 +540,12 @@ pub fn ArrayHashMapUnmanaged( | ... | @@ -538,6 +540,12 @@ pub fn ArrayHashMapUnmanaged( |
| 538 | /// Used to detect memory safety violations. | 540 | /// Used to detect memory safety violations. |
| 539 | pointer_stability: std.debug.SafetyLock = .{}, | 541 | pointer_stability: std.debug.SafetyLock = .{}, |
| 540 | 542 | ||
| 543 | /// A map containing no keys or values. | ||
| 544 | pub const empty: Self = .{ | ||
| 545 | .entries = .{}, | ||
| 546 | .index_header = null, | ||
| 547 | }; | ||
| 548 | |||
| 541 | /// Modifying the key is allowed only if it does not change the hash. | 549 | /// Modifying the key is allowed only if it does not change the hash. |
| 542 | /// Modifying the value is allowed. | 550 | /// Modifying the value is allowed. |
| 543 | /// Entry pointers become invalid whenever this ArrayHashMap is modified, | 551 | /// Entry pointers become invalid whenever this ArrayHashMap is modified, |
lib/std/array_list.zig+8| ... | @@ -618,6 +618,8 @@ pub fn ArrayListUnmanaged(comptime T: type) type { | ... | @@ -618,6 +618,8 @@ pub fn ArrayListUnmanaged(comptime T: type) type { |
| 618 | /// Functions that potentially allocate memory accept an `Allocator` parameter. | 618 | /// Functions that potentially allocate memory accept an `Allocator` parameter. |
| 619 | /// Initialize directly or with `initCapacity`, and deinitialize with `deinit` | 619 | /// Initialize directly or with `initCapacity`, and deinitialize with `deinit` |
| 620 | /// or use `toOwnedSlice`. | 620 | /// or use `toOwnedSlice`. |
| 621 | /// | ||
| 622 | /// Default initialization of this struct is deprecated; use `.empty` instead. | ||
| 621 | pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) type { | 623 | pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) type { |
| 622 | if (alignment) |a| { | 624 | if (alignment) |a| { |
| 623 | if (a == @alignOf(T)) { | 625 | if (a == @alignOf(T)) { |
| ... | @@ -638,6 +640,12 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ | ... | @@ -638,6 +640,12 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ |
| 638 | /// additional memory. | 640 | /// additional memory. |
| 639 | capacity: usize = 0, | 641 | capacity: usize = 0, |
| 640 | 642 | ||
| 643 | /// An ArrayList containing no elements. | ||
| 644 | pub const empty: Self = .{ | ||
| 645 | .items = &.{}, | ||
| 646 | .capacity = 0, | ||
| 647 | }; | ||
| 648 | |||
| 641 | pub const Slice = if (alignment) |a| ([]align(a) T) else []T; | 649 | pub const Slice = if (alignment) |a| ([]align(a) T) else []T; |
| 642 | 650 | ||
| 643 | pub fn SentinelSlice(comptime s: T) type { | 651 | pub fn SentinelSlice(comptime s: T) type { |
lib/std/hash_map.zig+9| ... | @@ -721,6 +721,8 @@ pub fn HashMap( | ... | @@ -721,6 +721,8 @@ pub fn HashMap( |
| 721 | /// the price of handling size with u32, which should be reasonable enough | 721 | /// the price of handling size with u32, which should be reasonable enough |
| 722 | /// for almost all uses. | 722 | /// for almost all uses. |
| 723 | /// Deletions are achieved with tombstones. | 723 | /// Deletions are achieved with tombstones. |
| 724 | /// | ||
| 725 | /// Default initialization of this struct is deprecated; use `.empty` instead. | ||
| 724 | pub fn HashMapUnmanaged( | 726 | pub fn HashMapUnmanaged( |
| 725 | comptime K: type, | 727 | comptime K: type, |
| 726 | comptime V: type, | 728 | comptime V: type, |
| ... | @@ -762,6 +764,13 @@ pub fn HashMapUnmanaged( | ... | @@ -762,6 +764,13 @@ pub fn HashMapUnmanaged( |
| 762 | /// Capacity of the first grow when bootstrapping the hashmap. | 764 | /// Capacity of the first grow when bootstrapping the hashmap. |
| 763 | const minimal_capacity = 8; | 765 | const minimal_capacity = 8; |
| 764 | 766 | ||
| 767 | /// A map containing no keys or values. | ||
| 768 | pub const empty: Self = .{ | ||
| 769 | .metadata = null, | ||
| 770 | .size = 0, | ||
| 771 | .available = 0, | ||
| 772 | }; | ||
| 773 | |||
| 765 | // This hashmap is specially designed for sizes that fit in a u32. | 774 | // This hashmap is specially designed for sizes that fit in a u32. |
| 766 | pub const Size = u32; | 775 | pub const Size = u32; |
| 767 | 776 |
lib/std/heap/general_purpose_allocator.zig+11| ... | @@ -157,6 +157,7 @@ pub const Config = struct { | ... | @@ -157,6 +157,7 @@ pub const Config = struct { |
| 157 | 157 | ||
| 158 | pub const Check = enum { ok, leak }; | 158 | pub const Check = enum { ok, leak }; |
| 159 | 159 | ||
| 160 | /// Default initialization of this struct is deprecated; use `.init` instead. | ||
| 160 | pub fn GeneralPurposeAllocator(comptime config: Config) type { | 161 | pub fn GeneralPurposeAllocator(comptime config: Config) type { |
| 161 | return struct { | 162 | return struct { |
| 162 | backing_allocator: Allocator = std.heap.page_allocator, | 163 | backing_allocator: Allocator = std.heap.page_allocator, |
| ... | @@ -174,6 +175,16 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { | ... | @@ -174,6 +175,16 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { |
| 174 | 175 | ||
| 175 | const Self = @This(); | 176 | const Self = @This(); |
| 176 | 177 | ||
| 178 | /// The initial state of a `GeneralPurposeAllocator`, containing no allocations and backed by the system page allocator. | ||
| 179 | pub const init: Self = .{ | ||
| 180 | .backing_allocator = std.heap.page_allocator, | ||
| 181 | .buckets = [1]Buckets{.{}} ** small_bucket_count, | ||
| 182 | .cur_buckets = [1]?*BucketHeader{null} ** small_bucket_count, | ||
| 183 | .large_allocations = .{}, | ||
| 184 | .empty_buckets = if (config.retain_metadata) .{} else {}, | ||
| 185 | .bucket_node_pool = .init(std.heap.page_allocator), | ||
| 186 | }; | ||
| 187 | |||
| 177 | const total_requested_bytes_init = if (config.enable_memory_limit) @as(usize, 0) else {}; | 188 | const total_requested_bytes_init = if (config.enable_memory_limit) @as(usize, 0) else {}; |
| 178 | const requested_memory_limit_init = if (config.enable_memory_limit) @as(usize, math.maxInt(usize)) else {}; | 189 | const requested_memory_limit_init = if (config.enable_memory_limit) @as(usize, math.maxInt(usize)) else {}; |
| 179 | 190 |