aboutsummaryrefslogtreecommitdiff
path: root/lib/std/hash_map.zig
AgeCommit message (Collapse)Author
2025-10-29std.hash_map: tune slow unit testsAndrew Kelley
These are the only two unit tests that take longer than 1s on my computer.
2025-09-11use pointer subtractionmarko
2025-08-11std.ArrayList: make unmanaged the defaultAndrew Kelley
2025-08-03zig fmt: apply new cast builtin orderJustus Klausecker
2025-04-13std: eradicate u29 and embrace std.mem.AlignmentAndrew Kelley
2025-02-06std.hash_map: placeholder for doc commentsAndrew Kelley
2025-01-06Remove strict verifyContext invocation from hash_map implementation. (#22370)cdeler
Fixes #19640 Co-authored-by: Andrew Kelley <andrew@ziglang.org>
2024-12-15hashmap: remove `inline` from `getIndex` now that we have `@branchHint`David Rubin
2024-11-22add assertLocked to std.debug.SafetyLockScott Redig
2024-09-12Replace deprecated default initializations with decl literalsLinus Groh
2024-09-10Dwarf: implement and test hash mapsJacob Young
2024-09-10Dwarf: implement and test multi array listJacob Young
2024-09-02std.hash_map: fix error message in getAutoHashFnJeremy Hertel
2024-09-01std: deprecate some incorrect default initializationsmlugg
In favour of newly-added decls, which can be used via decl literals.
2024-08-28std: update `std.builtin.Type` fields to follow naming conventionsmlugg
The compiler actually doesn't need any functional changes for this: Sema does reification based on the tag indices of `std.builtin.Type` already! So, no zig1.wasm update is necessary. This change is necessary to disallow name clashes between fields and decls on a type, which is a prerequisite of #9938.
2024-08-27compiler,lib,test,langref: migrate `@setCold` to `@branchHint`mlugg
2024-08-08std.hash_map: adding a rehash() method (#19923)John Benediktsson
see #17851
2024-07-23add std.testing.random_seedAndrew Kelley
closes #17609
2024-05-27hash_map.zig: Pass `self` by value and less pointer-int conversionSean
- Used `Self` instead of `*const Self` where appropriate (orignally proposed in #19770) - Replaced `@intFromPtr` and `@ptrFromInt` with `@ptrCast`, `@alignCast`, and pointer arithmetic where appropriate With this, the only remaining instance on pointer-int conversion in hash_map.zig is in `HashMapUnmanaged.removeByPtr`, which easily be able to be eliminated once pointer subtraction is supported.
2024-03-20std.hash_map: fix pointer lock safety false positiveAndrew Kelley
closes #19358
2024-03-16std: introduce pointer stability locks to hash maps (#17719)Andrew Kelley
This adds std.debug.SafetyLock and uses it in std.HashMapUnmanaged by adding lockPointers() and unlockPointers(). This provides a way to detect when an illegal modification has happened and panic rather than invoke undefined behavior.
2024-03-01compiler: audit debug mode checksJacob Young
* Introduce `-Ddebug-extensions` for enabling compiler debug helpers * Replace safety mode checks with `std.debug.runtime_safety` * Replace debugger helper checks with `!builtin.strip_debug_info` Sometimes, you just have to debug optimized compilers...
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-02-24std.hash_map: Fix integer overflow bugs (#19048)Brandon Botsch
2024-02-22Module: fix `@embedFile` of files containing zero bytesJacob Young
If an adapted string key with embedded nulls was put in a hash map with `std.hash_map.StringIndexAdapter`, then an incorrect hash would be entered for that entry such that it is possible that when looking for the exact key that matches the prefix of the original key up to the first null would sometimes match this entry due to hash collisions and sometimes not if performed later after a grow + rehash, causing the same key to exist with two different indices breaking every string equality comparison ever, for example claiming that a container type doesn't contain a field because the field name string in the struct and the string representing the identifier to lookup might be equal strings but have different string indices. This could maybe be fixed by changing `std.hash_map.StringIndexAdapter.hash` to only hash up to the first null, therefore ensuring that the entry's hash is correct and that all future lookups will be consistent, but I don't trust anything so instead I assert that there are no embedded nulls.
2024-02-08Replace std.rand references with std.Randome4m2
2023-12-23std.hash_map: clarify error when Context is missing pub hash/eqlAlliedEnvy
2023-11-22std: remove meta.traitAndrew Kelley
In general, I don't like the idea of std.meta.trait, and so I am providing some guidance by deleting the entire namespace from the standard library and compiler codebase. My main criticism is that it's overcomplicated machinery that bloats compile times and is ultimately unnecessary given the existence of Zig's strong type system and reference traces. Users who want this can create a third party package that provides this functionality. closes #18051
2023-11-19lib: correct unnecessary uses of 'var'mlugg
2023-10-23x86_64: implement 128-bit builtinsJacob Young
* `@clz` * `@ctz` * `@popCount` * `@byteSwap` * `@bitReverse` * various encodings used by std
2023-10-22Revert "Revert "Merge pull request #17637 from jacobly0/x86_64-test-std""Jacob Young
This reverts commit 6f0198cadbe29294f2bf3153a27beebd64377566.
2023-10-22Revert "Merge pull request #17637 from jacobly0/x86_64-test-std"Andrew Kelley
This reverts commit 0c99ba1eab63865592bb084feb271cd4e4b0357e, reversing changes made to 5f92b070bf284f1493b1b5d433dd3adde2f46727. This caused a CI failure when it landed in master branch due to a 128-bit `@byteSwap` in std.mem.
2023-10-22Merge pull request #17637 from jacobly0/x86_64-test-stdJacob Young
x86_64: start to enable `test-std` and `test-compiler-rt` testing
2023-10-21Fix simple doc mistakes. (#17624)JustinWayland
* Add missing period in Stack's description This looks fine in the source, but looks bad when seen on the documentation website. * Correct documentation for attachSegfaultHandler() The description for attachSegfaultHandler() looks pretty bad without indicating that the stuff at the end is code * Added missing 'the's in Queue.put's documentation * Fixed several errors in Stack's documentation `push()` and `pop()` were not styled as code There was no period after `pop()`, which looks bad on the documentation. * Fix multiple problems in base64.zig Both "invalid"s in Base64.decoder were not capitalized. Missing period in documentation of Base64DecoderWithIgnore.calcSizeUpperBound. * Fix capitalization typos in bit_set.zig In DynamicBitSetUnmanaged.deinit's and DynamicBitSet.deinit's documentation, "deinitializes" was uncapitalized. * Fix typos in fifo.zig's documentation Added a previously missing period to the end of the first line of LinearFifo.writableSlice's documentation. Added missing periods to both lines of LinearFifo.pump's documentation. * Fix typos in fmt.bufPrint's documentation The starts of both lines were not capitalized. * Fix minor documentation problems in fs/file.zig Missing periods in documentation for Permissions.setReadOnly, PermissionsWindows.setReadOnly, MetadataUnix.created, MetadataLinux.created, and MetadataWindows.created. * Fix a glaring typo in enums.zig * Correct errors in fs.zig * Fixed documentation problems in hash_map.zig The added empty line in verify_context's documentation is needed, otherwise autodoc for some reason assumes that the list hasn't been terminated and continues reading off the rest of the documentation as if it were part of the second list item. * Added lines between consecutive URLs in http.zig Makes the documentation conform closer to what was intended. * Fix wrongfully ended sentence in Uri.zig * Handle wrongly entered comma in valgrind.zig. * Add missing periods in wasm.zig's documentation * Fix odd spacing in event/loop.zig * Add missing period in http/Headers.zig * Added missing period in io/limited_reader.zig This isn't in the documentation due to what I guess is a limitation of autodoc, but it's clearly supposed to be. If it was, it would look pretty bad. * Correct documentation in math/big/int.zig * Correct formatting in math/big/rational.zig * Create an actual link to ZIGNOR's paper. * Fixed grammatical issues in sort/block.zig This will not show up in the documentation currently. * Fix typo in hash_map.zig
2023-10-21x86_64: disable failing tests, enable test-std testingJacob Young
2023-10-20std.hash_map: add `const` attribute to StringIndexContext.bytes and ...Constantin Bilz
StringIndexAdapter.bytes Without this change, constructing a Context/Adapter for a `const` string table requires a `@constCast`.
2023-08-06std: remove some unused imports (#16710)Zachary Raineri
2023-07-24Use builtin inference over @as where possibleZachary Raineri
2023-07-20std.hash_map: Fix casing of keyPtr variablesLinus Groh
The only case where those should be written in camelCase is if they were function pointers, which they aren't.
2023-06-24all: migrate code to new cast builtin syntaxmlugg
Most of this migration was performed automatically with `zig fmt`. There were a few exceptions which I had to manually fix: * `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten * `@truncate`'s fixup is incorrect for vectors * Test cases are not formatted, and their error locations change
2023-06-19all: zig fmt and rename "@XToY" to "@YFromX"Eric Joldasov
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-17mem: rename align*Generic to mem.align*Motiejus Jakštys
Anecdote 1: The generic version is way more popular than the non-generic one in Zig codebase: git grep -w alignForward | wc -l 56 git grep -w alignForwardGeneric | wc -l 149 git grep -w alignBackward | wc -l 6 git grep -w alignBackwardGeneric | wc -l 15 Anecdote 2: In my project (turbonss) that does much arithmetic and alignment I exclusively use the Generic functions. Anecdote 3: we used only the Generic versions in the Macho Man's linker workshop.
2023-06-16migration: std.math.{min, min3, max, max3} -> `@min` & `@max`r00ster91
2023-06-10std.hash_map: fetchRemove increment availablesentientwaffle
To avoid leaking slots, `fetchRemove` must increment `available` (when the "fetch" succeeds). Without the `available += 1`, the added test `"std.hash_map repeat fetchRemove"` fails with run test std-x86-linux-none-Debug: error: thread 432734 panic: integer overflow .../zig/lib/std/hash_map.zig:1365:28: 0x6471d5 in getOrPutAssumeCapacityAdapted__anon_47495 (test) self.available -= 1; ^ .../zig/lib/std/hash_map.zig:1308:62: 0x616950 in getOrPutAssumeCapacityContext (test) const result = self.getOrPutAssumeCapacityAdapted(key, ctx); ^ Alternatively, `fetchRemove` could call `removeByIndex`, though that would entail calling `header()` twice instead of once.
2023-05-29Prevent analysis of functions only referenced at comptimemlugg
The idea here is that there are two ways we can reference a function at runtime: * Through a direct call, i.e. where the function is comptime-known * Through a function pointer This means we can easily perform a form of rudimentary escape analysis on functions. If we ever see a `decl_ref` or `ref` of a function, we have a function pointer, which could "leak" into runtime code, so we emit the function; but for a plain `decl_val`, there's no need to. This change means that `comptime { _ = f; }` no longer forces a function to be emitted, which was used for some things (mainly tests). These use sites have been replaced with `_ = &f;`, which still triggers analysis of the function body, since you're taking a pointer to the function. Resolves: #6256 Resolves: #15353
2023-05-08Disallow named test decls with duplicate namesDominic
2023-04-30std: fix a bunch of typosLinus Groh
The majority of these are in comments, some in doc comments which might affect the generated documentation, and a few in parameter names - nothing that should be breaking, however.
2023-04-25zig fmtAndrew Kelley
2023-04-25change semantics of `@memcpy` and `@memset`Andrew Kelley
Now they use slices or array pointers with any element type instead of requiring byte pointers. This is a breaking enhancement to the language. The safety check for overlapping pointers will be implemented in a future commit. closes #14040
2023-04-22doc: fix minor grammar issues-k