From 26d92017d3b36cff940dcb7d1611c42232edb81a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 29 Aug 2016 17:28:20 +0200 Subject: Add builtin function "partition" The implementation of "partition" in Nixpkgs is O(n^2) (because of the use of ++), and for some reason was causing stack overflows in multi-threaded evaluation (not sure why). This reduces "nix-env -qa --drv-path" runtime by 0.197s and memory usage by 298 MiB (in non-Boehm mode). --- tests/lang/eval-okay-partition.exp | 1 + tests/lang/eval-okay-partition.nix | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 tests/lang/eval-okay-partition.exp create mode 100644 tests/lang/eval-okay-partition.nix (limited to 'tests') diff --git a/tests/lang/eval-okay-partition.exp b/tests/lang/eval-okay-partition.exp new file mode 100644 index 000000000000..cd8b8b020c05 --- /dev/null +++ b/tests/lang/eval-okay-partition.exp @@ -0,0 +1 @@ +{ right = [ 0 2 4 6 8 10 100 102 104 106 108 110 ]; wrong = [ 1 3 5 7 9 101 103 105 107 109 ]; } diff --git a/tests/lang/eval-okay-partition.nix b/tests/lang/eval-okay-partition.nix new file mode 100644 index 000000000000..846d2ce49486 --- /dev/null +++ b/tests/lang/eval-okay-partition.nix @@ -0,0 +1,5 @@ +with import ./lib.nix; + +builtins.partition + (x: x / 2 * 2 == x) + (builtins.concatLists [ (range 0 10) (range 100 110) ]) -- cgit 1.4.1