From ebffa9fd06af825d161d9da8d43f93ddb6b1f313 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Domen=20Ko=C5=BEar?= <domen@dev.si>
Date: Wed, 10 Aug 2016 12:02:58 +0200
Subject: [PATCH] flatten: drastically improve performance, see #17626

---
 lib/lists.nix | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/lists.nix b/lib/lists.nix
index 6712e5cc93f..78ffa753ac3 100644
--- a/lib/lists.nix
+++ b/lib/lists.nix
@@ -89,7 +89,7 @@ rec {
   */
   flatten = x:
     if isList x
-    then foldl' (x: y: x ++ (flatten y)) [] x
+    then concatMap (y: flatten y) x
     else [x];
 
   /* Remove elements equal to 'e' from a list.  Useful for buildInputs.