diff options
| author | Ryan Liptak <squeek502@hotmail.com> | 2021-11-01 00:54:04 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-11-04 14:54:25 -0400 |
| commit | e97feb96e4daf7d53538c9c8773d50459a59e5ee (patch) | |
| tree | 33474da46590a20370d970d033a3123b620b2f81 /src/Compilation.zig | |
| parent | d03e9d0b8347a74d674bdafadb71e7ddd8fdfad1 (diff) | |
| download | zig-e97feb96e4daf7d53538c9c8773d50459a59e5ee.tar.gz zig-e97feb96e4daf7d53538c9c8773d50459a59e5ee.zip | |
Replace ArrayList.init/ensureTotalCapacity pairs with initCapacity
Because ArrayList.initCapacity uses 'precise' capacity allocation, this should save memory on average, and definitely will save memory in cases where ArrayList is used where a regular allocated slice could have also be used.
Diffstat (limited to 'src/Compilation.zig')
| -rw-r--r-- | src/Compilation.zig | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index 385a98401a..4a8d9aec02 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -3812,8 +3812,7 @@ fn detectLibCIncludeDirs( } fn detectLibCFromLibCInstallation(arena: *Allocator, target: Target, lci: *const LibCInstallation) !LibCDirs { - var list = std.ArrayList([]const u8).init(arena); - try list.ensureTotalCapacity(4); + var list = try std.ArrayList([]const u8).initCapacity(arena, 4); list.appendAssumeCapacity(lci.include_dir.?); |
