aboutsummaryrefslogtreecommitdiff
path: root/lib/std/std.zig
diff options
context:
space:
mode:
authorTravis Staloch <1562827+travisstaloch@users.noreply.github.com>2024-04-20 23:14:39 -0700
committerAndrew Kelley <andrew@ziglang.org>2024-04-22 15:31:41 -0700
commit8af59d1f98266bd70b3afb44d196bbd151cedf22 (patch)
tree64b0c48f2b2d222629acbd5698c1f5310fdc708f /lib/std/std.zig
parentfefdbca6e62145a20777789961262f15c2bf6cbe (diff)
downloadzig-8af59d1f98266bd70b3afb44d196bbd151cedf22.tar.gz
zig-8af59d1f98266bd70b3afb44d196bbd151cedf22.zip
ComptimeStringMap: return a regular struct and optimize
this patch renames ComptimeStringMap to StaticStringMap, makes it accept only a single type parameter, and return a known struct type instead of an anonymous struct. initial motivation for these changes was to reduce the 'very long type names' issue described here https://github.com/ziglang/zig/pull/19682. this breaks the previous API. users will now need to write: `const map = std.StaticStringMap(T).initComptime(kvs_list);` * move `kvs_list` param from type param to an `initComptime()` param * new public methods * `keys()`, `values()` helpers * `init(allocator)`, `deinit(allocator)` for runtime data * `getLongestPrefix(str)`, `getLongestPrefixIndex(str)` - i'm not sure these belong but have left in for now incase they are deemed useful * performance notes: * i posted some benchmarking results here: https://github.com/travisstaloch/comptime-string-map-revised/issues/1 * i noticed a speedup reducing the size of the struct from 48 to 32 bytes and thus use u32s instead of usize for all length fields * i noticed speedup storing KVs as a struct of arrays * latest benchmark shows these wall_time improvements for debug/safe/small/fast builds: -6.6% / -10.2% / -19.1% / -8.9%. full output in link above.
Diffstat (limited to 'lib/std/std.zig')
-rw-r--r--lib/std/std.zig6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/std/std.zig b/lib/std/std.zig
index 8aa12ff31a..bd8c6db276 100644
--- a/lib/std/std.zig
+++ b/lib/std/std.zig
@@ -16,8 +16,8 @@ pub const BufMap = @import("buf_map.zig").BufMap;
pub const BufSet = @import("buf_set.zig").BufSet;
/// Deprecated: use `process.Child`.
pub const ChildProcess = @import("child_process.zig").ChildProcess;
-pub const ComptimeStringMap = comptime_string_map.ComptimeStringMap;
-pub const ComptimeStringMapWithEql = comptime_string_map.ComptimeStringMapWithEql;
+pub const StaticStringMap = static_string_map.StaticStringMap;
+pub const StaticStringMapWithEql = static_string_map.StaticStringMapWithEql;
pub const DoublyLinkedList = @import("linked_list.zig").DoublyLinkedList;
pub const DynLib = @import("dynamic_library.zig").DynLib;
pub const DynamicBitSet = bit_set.DynamicBitSet;
@@ -62,7 +62,7 @@ pub const builtin = @import("builtin.zig");
pub const c = @import("c.zig");
pub const coff = @import("coff.zig");
pub const compress = @import("compress.zig");
-pub const comptime_string_map = @import("comptime_string_map.zig");
+pub const static_string_map = @import("static_string_map.zig");
pub const crypto = @import("crypto.zig");
pub const debug = @import("debug.zig");
pub const dwarf = @import("dwarf.zig");