neovim: collect plugin configs with filter and map
generatedConfigs built its list with a non-strict foldl that appended via acc ++ [ p.config ], an O(n^2) pattern. Filtering out null configs and mapping is equivalent, order-preserving, and avoids the repeated list copies.
This commit is contained in:
@@ -556,7 +556,7 @@ in
|
||||
generatedConfigs =
|
||||
let
|
||||
grouped = lib.groupBy (x: x.type) pluginsNormalized;
|
||||
configsOnly = lib.foldl (acc: p: if p.config != null then acc ++ [ p.config ] else acc) [ ];
|
||||
configsOnly = ps: map (p: p.config) (lib.filter (p: p.config != null) ps);
|
||||
in
|
||||
lib.mapAttrs (_name: vals: lib.concatStringsSep "\n" (configsOnly vals)) grouped;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user