Commit graph

37 commits

Author SHA1 Message Date
Ryan Liptak
16b3d1004e Remove redundant test name prefixes now that test names are fully qualified
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-26 15:18:31 -08:00
e4m2
8d56e472c9 Replace std.rand references with std.Random 2024-02-08 15:21:35 +01:00
mlugg
51595d6b75
lib: correct unnecessary uses of 'var' 2023-11-19 09:55:07 +00:00
Jacob Young
8f69e977f1 x86_64: implement 128-bit builtins
* `@clz`
 * `@ctz`
 * `@popCount`
 * `@byteSwap`
 * `@bitReverse`
 * various encodings used by std
2023-10-23 22:42:18 -04:00
Jacob Young
27fe945a00 Revert "Revert "Merge pull request #17637 from jacobly0/x86_64-test-std""
This reverts commit 6f0198cadb.
2023-10-22 15:46:43 -04:00
Andrew Kelley
6f0198cadb Revert "Merge pull request #17637 from jacobly0/x86_64-test-std"
This reverts commit 0c99ba1eab, reversing
changes made to 5f92b070bf.

This caused a CI failure when it landed in master branch due to a
128-bit `@byteSwap` in std.mem.
2023-10-22 12:16:35 -07:00
Jacob Young
32e85d44eb x86_64: disable failing tests, enable test-std testing 2023-10-21 10:55:41 -04:00
Alexander Heinrich
4e188dd66c Update docs of PriorityQueue.iterator() and PriorityDeque.iterator() 2023-10-12 04:48:22 +03:00
Niles Salter
82470d4f89 [priority_dequeue] Fix out-of-bounds access
This makes it so `first_child_index` will not be accessed when it is equal to `self.len`. (i.e. `self.items[self.len]` will not happen) The access itself was "safe" (as in, `self.len < self.items.len`) because we were only calling `doSiftDown` in the case where there was a stale value at `self.items[self.len]`. However, it is still technically a bug, and can manifest by an unnecessary comparison of a value to a copy of itself.
2023-06-22 02:03:53 -07:00
Niles Salter
ff5850183e [priority_deque] simplify & optimize isMinLayer
LLVM has trouble compiling the old implementation, (presumably) because `leading_zeros` is thought to be a `u7` rather than a `u6`, which means `63 - clz` is not equivalent to `63 ^ clz`, which means it can't deduce that the final condition can simply be flipped. (I am assuming `usize` is a `u64` here for ease of understanding, but it's the same for any power of 2)

https://zig.godbolt.org/z/Pbj4P7ob3

The new version is slightly better too because `isMinLayer(maxInt(usize))` is now well-defined behavior.
2023-06-22 01:57:28 -07:00
Dominic
5a3eca5d4c
Disallow named test decls with duplicate names 2023-05-08 10:59:06 +03:00
Andrew Kelley
aeaef8c0ff update std lib and compiler sources to new for loop syntax 2023-02-18 19:17:21 -07:00
Frechdachs
478544239e
std: Fix update() method in PriorityQueue and PriorityDequeue (#13908)
Previously the update() method would iterate over its capacity, which may contain uninitialized memory or already removed elements.
2022-12-13 14:55:41 -05:00
Andrew Kelley
d3d24874c9 std: remove deprecated API for the upcoming release
See #3811
2022-09-16 14:46:53 -04:00
Veikka Tuominen
62ff8871ed stage2+stage1: remove type parameter from bit builtins
Closes #12529
Closes #12511
Closes #6835
2022-08-22 11:19:20 +03:00
VÖRÖSKŐI András
370793a36b PriorityDequeue: use compareFn in update() method 2022-07-25 18:12:32 +03:00
Arnavion
22e1d92d3e std.priority_dequeue: allow comparator to take a context parameter 2021-12-15 17:46:10 -08:00
Lee Cannon
85de022c56
allocgate: std Allocator interface refactor 2021-11-30 23:32:47 +00:00
Andrew Kelley
902df103c6 std lib API deprecations for the upcoming 0.9.0 release
See #3811
2021-11-30 00:13:07 -07:00
Ominitay
c1a5ff34f3 std.rand: Refactor Random interface
These changes have been made to resolve issue #10037. The `Random`
interface was implemented in such a way that causes significant slowdown
when calling the `fill` function of the rng used.

The `Random` interface is no longer stored in a field of the rng, and is
instead returned by the child function `random()` of the rng. This
avoids the performance issues caused by the interface.
2021-10-27 16:07:48 -04:00
Max Hollmann
53b87fa78a Move compareFn from init to type constructor in PriorityQueue and PriorityDequeue.
This change significantly improves performance for simple compare functions and modifies
the API to be more consistent with e.g. `HashMap`.
2021-10-17 17:47:43 -04:00
Ryan Liptak
feeb25908b std.PriorityDequeue: ensureUnusedCapacity and ensureTotalCapacity
Same as c8ae581fef, but for PriorityDequeue.
2021-09-19 13:52:56 +02: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
Jacob G-W
9fffffb07b fix code broken from previous commit 2021-06-21 17:03:03 -07:00
Matthew Borkowski
40a47eae65 fix shrinkAndFree and remove shrinkRetainingCapacity in PriorityQueue and PriorityDequeue 2021-05-12 18:33:25 -04:00
Veikka Tuominen
fd77f2cfed std: update usage of std.testing 2021-05-08 15:15:30 +03:00
Zander Khan
ce22c70586 Change compareFn to fn (a: T, b: T) std.math.Order 2021-01-18 19:02:11 +00:00
Zander Khan
5bfd9238de Remove resize. Adding uninitialized memory at the end of the items would break the heap property. 2021-01-17 14:43:38 +00:00
Zander Khan
9a09ebb1b9 Replace shrink with shrinkAndFree and shrinkRetainingCapacity 2021-01-17 14:41:20 +00:00
Zander Khan
e1ab425bce Fix slice length when updating 2021-01-16 18:43:13 +00:00
Zander Khan
c6986f29f9 Fix update might change an element no longer in the queue 2021-01-16 18:11:26 +00:00
Zander Khan
4600b489a6 Rename heap to queue in tests for consistency 2021-01-16 18:09:44 +00:00
Zander Khan
4d09803414 Fix edge cases in fromOwnedSlice 2021-01-16 18:06:44 +00:00
Zander Khan
a162a21947 Ensure we cannot remove an item outside the current length of the queue 2021-01-16 17:52:14 +00:00
Zander Khan
ecee1cae45 Remove magic number 2021-01-16 17:48:55 +00:00
Zander Khan
349ccc0bd0 Add license to top of file 2021-01-16 17:48:14 +00:00
Zander Khan
a727a508cd std: Add Priority Dequeue 2021-01-16 12:01:06 +00:00