summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorBen Siraphob <bensiraphob@gmail.com>2021-11-02 02:46:27 -0500
committerGitHub <noreply@github.com>2021-11-02 02:46:27 -0500
commit481afad2658993463d390b184e259d73fcd374ea (patch)
tree1192ae6190aa60368fc199303e612c65d370b5e3 /lib
parent94d91a448b87a70204485bd768977c07575911e8 (diff)
parentcd6397519fe8f94fae3646050d8742b11e287bfa (diff)
downloadnixpkgs-481afad2658993463d390b184e259d73fcd374ea.tar
nixpkgs-481afad2658993463d390b184e259d73fcd374ea.tar.gz
nixpkgs-481afad2658993463d390b184e259d73fcd374ea.tar.bz2
nixpkgs-481afad2658993463d390b184e259d73fcd374ea.tar.lz
nixpkgs-481afad2658993463d390b184e259d73fcd374ea.tar.xz
nixpkgs-481afad2658993463d390b184e259d73fcd374ea.tar.zst
nixpkgs-481afad2658993463d390b184e259d73fcd374ea.zip
Merge pull request #144072 from polykernel/lib-lists-mutuallyexclusive-optimization
Diffstat (limited to 'lib')
-rw-r--r--lib/lists.nix7
1 files changed, 2 insertions, 5 deletions
diff --git a/lib/lists.nix b/lib/lists.nix
index e469f3ef265..1dbff7668d7 100644
--- a/lib/lists.nix
+++ b/lib/lists.nix
@@ -642,7 +642,7 @@ rec {
        unique [ 3 2 3 4 ]
        => [ 3 2 4 ]
    */
- unique = foldl' (acc: e: if elem e acc then acc else acc ++ [ e ]) [];
+  unique = foldl' (acc: e: if elem e acc then acc else acc ++ [ e ]) [];
 
   /* Intersects list 'e' and another list. O(nm) complexity.
 
@@ -663,9 +663,6 @@ rec {
   /* Test if two lists have no common element.
      It should be slightly more efficient than (intersectLists a b == [])
   */
-  mutuallyExclusive = a: b:
-    (builtins.length a) == 0 ||
-    (!(builtins.elem (builtins.head a) b) &&
-     mutuallyExclusive (builtins.tail a) b);
+  mutuallyExclusive = a: b: length a == 0 || !(any (x: elem x a) b);
 
 }