From a709ca8240d4ecd960f282bd3b64ab6256684f41 Mon Sep 17 00:00:00 2001 From: Eman Resu <78693624+quatquatt@users.noreply.github.com> Date: Sat, 16 May 2026 00:29:39 -0400 Subject: [PATCH] lib.strings.splitString: compute escaped separator early Thanks to moving the existing let variable out, this should have identical performance for non-memoised calls, and improved performance when caching the separator. --- lib/strings.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/strings.nix b/lib/strings.nix index 53dc515ac3f8..5425a4a66590 100644 --- a/lib/strings.nix +++ b/lib/strings.nix @@ -1740,11 +1740,11 @@ rec { ::: */ splitString = - sep: s: + sep: let - splits = filter isString (split (escapeRegex (toString sep)) (toString s)); + escapedSep = escapeRegex (toString sep); in - map (addContextFrom s) splits; + s: map (addContextFrom s) (filter isString (split escapedSep (toString s))); /** Splits a string into substrings based on a predicate that examines adjacent characters.