Commit graph

21 commits

Author SHA1 Message Date
Ali Cheraghi
dec1163fbb
all: replace all @Type usages
Co-authored-by: Matthew Lugg <mlugg@mlugg.co.uk>
2025-11-22 22:42:38 +00:00
Andrew Kelley
73c98ca0e6 simplify std.hash.Adler32 2025-07-31 22:10:11 -07:00
Andrew Kelley
a0d1682921 std.hash.RapidHash: remove
Its design keeps evolving. See
https://github.com/Nicoshev/rapidhash/releases

It's great to see the design improving, but over time, this will lead to
code rot; versions that aren't widely used but would still have to live
in the standard library forever and be maintained.

Better to be maintained as an external dependency that applications can
opt into. Then, in a few years, if a version proves to be stable and
widely adopted, it could be considered for inclusion in the standard
library.
2025-07-19 11:49:33 -07:00
Linus Groh
eb37552536 Remove numerous things deprecated during the 0.14 release cycle
Basically everything that has a direct replacement or no uses left.

Notable omissions:

- std.ArrayHashMap: Too much fallout, needs a separate cleanup.
- std.debug.runtime_safety: Too much fallout.
- std.heap.GeneralPurposeAllocator: Lots of references to it remain, not
  a simple find and replace as "debug allocator" is not equivalent to
  "general purpose allocator".
- std.io.Reader: Is being reworked at the moment.
- std.unicode.utf8Decode(): No replacement, needs a new API first.
- Manifest backwards compat options: Removal would break test data used
  by TestFetchBuilder.
- panic handler needs to be a namespace: Many tests still rely on it
  being a function, needs a separate cleanup.
2025-07-11 08:17:43 +02:00
Chris Covington
b7512c3e5d
Add rapidhash (#22085) 2025-02-22 14:32:48 -08:00
Andrew Kelley
ca67f80b6e std.hash.int: avoid words like "easy" and "fast" in doc comments 2024-11-24 15:30:52 -08:00
Francesco Alemanno
ae6c24b490 std.hash.int: better handle odd bit sizes
Uses the non rational solution of a quadratic, I made it work up to 256
bits, added Mathematica code in case anyone wants to verify the magic
constant.

integers between sizes 3...15 were affected by fatal bias, it is best to
make them pass through the generic solution.

Thanks to RetroDev256 & Andrew feedback.
2024-11-24 15:29:20 -08:00
Andrew Kelley
d09fd249c0 std.hash.int: restore previous behavior
In the parent commit, I handled odd bit sizes by upcasting and
truncating. However it seems the else branch is intended to handle
those cases instead, so this commit reverts that behavior.
2024-11-24 15:27:03 -08:00
Andrew Kelley
5ad44c14b0 std.hash.int: use anytype instead of explicit type parameter
also
* allow signed ints, simply bitcast them to unsigned
* handle odd bit sizes by upcasting and then truncating
* naming conventions
* remove redundant code
* better use of testing API
2024-11-24 15:27:03 -08:00
Francesco Alemanno
aee6f7d7ee std.hash: improve simple hashing of unsigned integers
Before, the default bit mixer was very biased, and after a
lot of searching it turns out that selecting a better solution is hard.

I wrote a custom statistical analysis taylored for bit mixers in order
to select the best one at each size (u64/u32/u16), compared a lot of
mixers, and packaged the best ones in this commit.
2024-11-24 15:27:03 -08:00
David
5c8912d7a4
XXH3 Implementation for Zig STD (#17530)
XXH3 is the faster alternative to XXH64 which utilizes SIMD
when hashing large chunks of memory and similar mixing to
WyHash (64x64 -> 128 mul) for smaller inputs.

Co-authored-by: Reixcon226 <87927264+Rexicon226@users.noreply.github.com>

---------

Co-authored-by: kprotty <kbutcher6200@gmail.com>
2023-10-17 13:55:01 -05:00
Andrew Kelley
1c7095cb7d add std.hash.uint32
This is handy if you have a u32 and want a u32 and don't want to take a
detour through many layers of abstraction elsewhere in the std.hash
namespace.
Copied from https://nullprogram.com/blog/2018/07/31/
2023-06-10 20:42:30 -07:00
Jacob Young
3f1c51ca90 std: remove names from incorrectly named tests
Tests that only reference decls for the purpose of analyzing more tests
should be unnamed, otherwise trying to filter for just a referenced test
can become impossible depending on the names.
2023-04-21 23:08:48 -04:00
dweiller
19984d8751 std.hash: add XxHash64 and XxHash32 2023-02-20 09:09:05 +11:00
Meghan
c08b190c69
lint: duplicate import (#10519) 2022-01-07 00:06:06 -05:00
Andrew Kelley
d29871977f remove redundant license headers from zig standard library
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-24 12:25:09 -07:00
Frank Denis
6c2e0c2046 Year++ 2020-12-31 15:45:24 -08:00
Frank Denis
e919744c7a Promote hash/siphash to crypto/siphash
SipHash *is* a cryptographic function, with a 128-bit security level.

However, it is not a regular hash function: a secret key is required,
and knowledge of that key allows collisions to be quickly computed offline.

SipHash is therefore more suitable to be used as a MAC.

The same API as other MACs was implemented in addition to functions directly
returning an integer.

The benchmarks have been updated accordingly.

No changes to the SipHash implementation itself.
2020-08-22 02:47:50 -04:00
Andrew Kelley
4a69b11e74 add license header to all std lib files
add SPDX license identifier
copyright ownership is zig contributors
2020-08-20 16:07:04 -04:00
Andrew Kelley
30a555eed4
merge dumps tool: merging ast nodes
-fgenerate-docs is replaced ith -femit-docs
-fno-emit-bin is added to prevent outputting binary
2019-10-11 18:13:24 -04:00
Andrew Kelley
ed36dbbd9c
mv std/ lib/
that's all this commit does. further commits will fix cli flags and
such.

see #2221
2019-09-25 23:35:41 -04:00
Renamed from std/hash.zig (Browse further)