diff options
author | Daniel Thwaites <danthwaites30@btinternet.com> | 2022-04-22 17:43:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-22 12:43:25 -0400 |
commit | 4f9b8a07024c3397d33df3f26906839cd03f0297 (patch) | |
tree | 7a72fb7d1a1bfb8440a00d5a8ba7abfd6d6e7289 /lib/strings.nix | |
parent | 114bfa7d5c4e618c1eafe79cc42975389307048e (diff) |
lib/strings: optimise hasInfix function (#168175)
* lib/strings: optimise hasInfix function * lib/strings: optimise hasInfix further using regex * rstudio: call hasInfix with a string * lib/strings: remove let from hasInfix Co-authored-by: pennae <82953136+pennae@users.noreply.github.com> Co-authored-by: pennae <82953136+pennae@users.noreply.github.com>
Diffstat (limited to 'lib/strings.nix')
-rw-r--r-- | lib/strings.nix | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/lib/strings.nix b/lib/strings.nix index 820d1901f945b..11066890ec3d3 100644 --- a/lib/strings.nix +++ b/lib/strings.nix @@ -253,10 +253,7 @@ rec { => false */ hasInfix = infix: content: - let - drop = x: substring 1 (stringLength x) x; - in hasPrefix infix content - || content != "" && hasInfix infix (drop content); + builtins.match ".*${escapeRegex infix}.*" content != null; /* Convert a string to a list of characters (i.e. singleton strings). This allows you to, e.g., map a function over each character. However, |