aboutsummaryrefslogtreecommitdiff
path: root/lib/std/comptime_string_map.zig
AgeCommit message (Collapse)Author
2024-04-22ComptimeStringMap: return a regular struct and optimizeTravis Staloch
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.
2024-02-26Remove redundant test name prefixes now that test names are fully qualifiedRyan Liptak
Follow up to #19079, which made test names fully qualified. This fixes tests that now-redundant information in their test names. For example here's a fully qualified test name before the changes in this commit: "priority_queue.test.std.PriorityQueue: shrinkAndFree" and the same test's name after the changes in this commit: "priority_queue.test.shrinkAndFree"
2024-01-19do not enforce function parameters to be marked comptime if only called at ↵Meghan Denny
comptime
2024-01-05std.CompTimeStringMap*: support empty initialization listPat Tullmann
Add tests for empty initialization, and some more corner cases (empty key, very long key, duplicate keys). Fixes #18212
2024-01-02std.ComptimeStringMap: allow getting kv indexMeghan Denny
2023-09-14ComptimeStringMap: Add version that takes an equality functionRyan Liptak
This will allow users to construct e.g. a ComptimeStringMap that uses case-insensitive ASCII comparison. Note: the previous ComptimeStringMap API is unchanged (i.e. this does not break any existing code).
2023-06-26std.sort.block: add safety check for lessThan return valueAli Chraghi
2023-05-23std.sort: add pdqsort and heapsortAli Chraghi
2023-04-22Add doc comments for ComptimeStringMapBogdan Romanyuk
Some parts of stdlib are still undocumented yet.
2023-02-18update std lib and compiler sources to new for loop syntaxAndrew Kelley
2022-12-08Re-apply: "std.ComptimeStringMap: use tuple types"r00ster91
096d3efae5fcaa5640f4acb2f9be2d7f93f7fdb2 was not the cause of the CI failure.
2022-12-08Revert "std.ComptimeStringMap: use tuple types"Andrew Kelley
This reverts commit 096d3efae5fcaa5640f4acb2f9be2d7f93f7fdb2. This commit is not passing a very important CI test that was recently added.
2022-12-07std.ComptimeStringMap: use tuple typesr00ster91
This is now possible due to #13627.
2021-08-24remove redundant license headers from zig standard libraryAndrew Kelley
We already have a LICENSE file that covers the Zig Standard Library. We no longer need to remind everyone that the license is MIT in every single file. Previously this was introduced to clarify the situation for a fork of Zig that made Zig's LICENSE file harder to find, and replaced it with their own license that required annual payments to their company. However that fork now appears to be dead. So there is no need to reinforce the copyright notice in every single file.
2021-08-13ComptimeStringMap: expose kvs array in returned structRyan Liptak
Allows for iterating over the kvs when constructing with a list literal instead of having to create a separate array to pass into ComptimeStringMap in order to maintain access to the values. For example when making a set, before in order to loop over the kvs you'd have to do something like: const MyKV = struct { @"0": []const u8 }; const kvs: []const MyKV = &[_]MyKV{ .{ @"0" = "foo"}, .{ @"0" = "bar" } }; const map = ComptimeStringMap(void, kvs); for (kvs) |kv| {} whereas now it's possible to do: const map = ComptimeStringMap(void, .{ .{"foo"}, .{"bar"} }); for (map.kvs) |kv| {}
2021-06-21fix code broken from previous commitJacob G-W
2021-06-15std: don't reference non-existant ComptimeStringHashMap typeBjörn Linse
2021-05-08std: update usage of std.testingVeikka Tuominen
2020-12-31Year++Frank Denis
2020-08-20add license header to all std lib filesAndrew Kelley
add SPDX license identifier copyright ownership is zig contributors
2020-07-11run zig fmt on std lib and self hostedVexu
2020-06-08std.sort: give comparator functions a context parameterAndrew Kelley
2020-05-26std.ComptimeStringMap: Add support for void value type (i.e. a set)Ryan Liptak
2020-05-26Add std.ComptimeStringMapRyan Liptak