d00229753d
In order to implement an asynchronous builtins.sort (required for moving builtins to generators), we need an `async` sorting algorithm as our comparators involve invoking a Nix function. This commit implements a fairly simple, optimised bubble sort as the sorting algorithm used in our `async fn sort_by`. There don't seem to be any crates providing async versions of things like this, and they might actually be pretty hard to implement generically due to some constraints about how `async` works. Note that this algorithm is less efficient than the hybrid "timsort/mergesort/insert sort" used in the Rust standard library. I tried to write a merge sort implementation, but ran into isuses with the sort becoming unstable because our comparators can not yield equality. This is the simplest implementation which I know to be correct. Note that as of this commit this is *not* covered by the Tvix test suite, but it will be as soon as the rest of the generator code lands. Change-Id: Ia9a604f7dd941d6acc9212c902e0e637ed75bebc Reviewed-on: https://cl.tvl.fyi/c/depot/+/8239 Reviewed-by: Adam Joseph <adam@westernsemico.com> Tested-by: BuildkiteCI |
||
---|---|---|
.. | ||
builtins | ||
compiler | ||
tests | ||
value | ||
vm | ||
chunk.rs | ||
errors.rs | ||
io.rs | ||
lib.rs | ||
nix_search_path.rs | ||
observer.rs | ||
opcode.rs | ||
pretty_ast.rs | ||
properties.rs | ||
source.rs | ||
spans.rs | ||
systems.rs | ||
test_utils.rs | ||
upvalues.rs | ||
vm.rs | ||
warnings.rs |