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.
This commit is contained in:
+3
-3
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user