aboutsummaryrefslogtreecommitdiff
path: root/lib/std/hash/auto_hash.zig
AgeCommit message (Collapse)Author
2025-09-17use block break instead of returnmarko
2025-01-16all: update to `std.builtin.Type.Pointer.Size` field renamesmlugg
This was done by regex substitution with `sed`. I then manually went over the entire diff and fixed any incorrect changes. This diff also changes a lot of `callconv(.C)` to `callconv(.c)`, since my regex happened to also trigger here. I opted to leave these changes in, since they *are* a correct migration, even if they're not the one I was trying to do!
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.
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-29x86_64: fix compiler rt test failuresJacob Young
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-21x86_64: disable failing tests, enable test-std testingJacob Young
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-13std.meta: remove `Vector` (deprecated in 0.10)Eric Joldasov
Followup to d42d31f72f38165f70c2850e9cc63da44b3b470c. Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-10std.hash: auto hash signed ints as bitcasts of unsigned intsAndrew Kelley
2023-06-07reimplement wyhash v4.1 (#15969)Marc Tiehuis
2023-05-20Zir: eliminate `field_call_bind` and `field_call_bind_named`mlugg
This commit removes the `field_call_bind` and `field_call_bind_named` ZIR instructions, replacing them with a `field_call` instruction which does the bind and call in one. `field_call_bind` is an unfortunate instruction. It's tied into one very specific usage pattern - its result can only be used as a callee. This means that it creates a value of a "pseudo-type" of sorts, `bound_fn` - this type used to exist in Zig, but now we just hide it from the user and have AstGen ensure it's only used in one way. This is quite silly - `Type` and `Value` should, as much as possible, reflect real Zig types and values. It makes sense to instead encode the `a.b()` syntax as its own ZIR instruction, so that's what we do here. This commit introduces a new instruction, `field_call`. It's like `call`, but rather than a callee ref, it contains a ref to the object pointer (`&a` in `a.b()`) and the string field name (`b`). This eliminates `bound_fn` from the language, and slightly decreases the size of generated ZIR - stats below. This commit does remove a few usages which used to be allowed: - `@field(a, "b")()` - `@call(.auto, a.b, .{})` - `@call(.auto, @field(a, "b"), .{})` These forms used to work just like `a.b()`, but are no longer allowed. I believe this is the correct choice for a few reasons: - `a.b()` is a purely *syntactic* form; for instance, `(a.b)()` is not valid. This means it is *not* inconsistent to not allow it in these cases; the special case here isn't "a field access as a callee", but rather this exact syntactic form. - The second argument to `@call` looks much more visually distinct from the callee in standard call syntax. To me, this makes it seem strange for that argument to not work like a normal expression in this context. - A more practical argument: it's confusing! `@field` and `@call` are used in very different contexts to standard function calls: the former normally hints at some comptime machinery, and the latter that you want more precise control over parts of a function call. In these contexts, you don't want implicit arguments adding extra confusion: you want to be very explicit about what you're doing. Lastly, some stats. I mentioned before that this change slightly reduces the size of ZIR - this is due to two instructions (`field_call_bind` then `call`) being replaced with one (`field_call`). Here are some numbers: +--------------+----------+----------+--------+ | File | Before | After | Change | +--------------+----------+----------+--------+ | Sema.zig | 4.72M | 4.53M | -4% | | AstGen.zig | 1.52M | 1.48M | -3% | | hash_map.zig | 283.9K | 276.2K | -3% | | math.zig | 312.6K | 305.3K | -2% | +--------------+----------+----------+--------+
2022-12-17std.builtin: rename Type.UnionField and Type.StructField's field_type to typer00ster91
2022-12-13update usages of `@call`Veikka Tuominen
2022-12-09Eliminate `BoundFn` type from the languageVeikka Tuominen
Closes #9484
2022-10-30std: re-enable auto hash testAndrew Kelley
It was temporarily disabled due to a self-hosted compiler miscompilation. closes #12178
2022-08-14Fix #12423: auto_hash not hashing arrays of slices uniquelyYujiri
2022-08-11fix error message when providing slice to `std.hash.autoHash`LordMZTE
2022-07-20disable std lib test failing with self-hosted ReleaseSafeAndrew Kelley
I opened a corresponding issue #12178 which has the 0.10.0 milestone, so this must be fixed before we release.
2022-03-08deprecated TypeInfo in favor of TypeJonathan Marler
Co-authored-by: Veikka Tuominen <git@vexu.eu>
2022-01-31std: make ArrayHashMap eql function accept an additional paramAndrew Kelley
which is the index of the key that already exists in the hash map. This enables the use case of using `AutoArrayHashMap(void, void)` which may seem surprising at first, but is actually pretty handy! This commit includes a proof-of-concept of how I want to use it, with a new InternArena abstraction for stage2 that provides a compact way to store values (and types) in an "internment arena", thus making types stored exactly once (per arena), representable with a single u32 as a reference to a type within an InternArena, and comparable with a simple u32 integer comparison. If both types are in the same InternArena, you can check if they are equal by seeing if their index is the same. What's neat about `AutoArrayHashMap(void, void)` is that it allows us to look up the indexes by key, *without actually storing the keys*. Instead, keys are treated as ephemeral values that are constructed as needed. As a result, we have an extremely efficient encoding of types and values, represented only by three arrays, which has no pointers, and can therefore be serialized and deserialized by a single writev/readv call. The `map` field is denormalized data and can be computed from the other two fields. This is in contrast to our current Type/Value system which makes extensive use of pointers. The test at the bottom of InternArena.zig passes in this commit.
2021-11-30allocgate: std Allocator interface refactorLee Cannon
2021-10-04migrate from `std.Target.current` to `@import("builtin").target`Andrew Kelley
closes #9388 closes #9321
2021-09-01re-enable mips behavior tests for vectorsAndrew Kelley
closes #3317
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-07-21Correct hasUniqueRepresentation for vectorsTau
Closes #9333.
2021-06-14std: fix auto hash of tagged union with void fieldIsaac Freund
2021-05-08Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgenAndrew Kelley
Conflicts: * doc/langref.html.in * lib/std/enums.zig * lib/std/fmt.zig * lib/std/hash/auto_hash.zig * lib/std/math.zig * lib/std/mem.zig * lib/std/meta.zig * test/behavior/alignof.zig * test/behavior/bitcast.zig * test/behavior/bugs/1421.zig * test/behavior/cast.zig * test/behavior/ptrcast.zig * test/behavior/type_info.zig * test/behavior/vector.zig Master branch added `try` to a bunch of testing function calls, and some lines also had changed how to refer to the native architecture and other `@import("builtin")` stuff.
2021-05-08std: update usage of std.testingVeikka Tuominen
2021-04-15std: change `@import("builtin")` to `std.builtin`Andrew Kelley
2021-03-21Specify type in autoHash error messageJoris Hartog
This commit simply specifies the type which `autoHash` can't hash in the compile error. Closes #7970.
2021-01-30Replace @TagType uses, mostly with std.meta.TagTadeo Kondrak
2020-12-31Year++Frank Denis
2020-12-26Handle unions in autoHashJulius Putra Tanu Setiaji
2020-12-26Also check whether structs contain slicesJulius Putra Tanu Setiaji
2020-12-17std: Don't hash undefined bitsLemonBoy
auto_hash must be extra careful when hashing integers whose bit size is not a multiple of 8 as, when reinterpreted with mem.asBytes, may contain undefined non-zero bits too.
2020-09-07Use less inefficient method of replacing TypeInfo.UnionField.enum_fieldTadeo Kondrak
2020-09-07Update standard library for removal of TypeInfo.UnionField.enum_fieldTadeo Kondrak
2020-09-03update uses of deprecated type field accessVexu
2020-08-20add license header to all std lib filesAndrew Kelley
add SPDX license identifier copyright ownership is zig contributors
2020-08-13translate-c: add return if one is neededVexu
2020-07-26make use of hasUniqueRepresentation to speed up hashing facilities, fastpath ↵Sahnvour
in getAutoHashFn is particularly important for hashmap performance gives a 1.18x speedup on gotta-go-fast hashmap bench
2020-07-26improve autoHash type switchSahnvour
floats shouldn't be autoHash'd as they have multiple representations for some values, preventing it by default is safer
2020-07-11run zig fmt on std lib and self hostedVexu
2020-05-06Optimization of vectors hashingdata-man
2020-04-28std.meta.IntType -> std.meta.IntTadeo Kondrak
2020-04-28@Vector -> std.meta.VectorTadeo Kondrak