summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSilvan Mosberger <silvan.mosberger@tweag.io>2023-08-14 23:29:18 +0200
committerSilvan Mosberger <silvan.mosberger@tweag.io>2023-08-14 23:32:42 +0200
commit150217c1ac10fbef93e03694f6955029249c9aa4 (patch)
tree7d19ab363ffd7a785f3c1cbe52073c5db3f92757 /lib
parentlib.removePrefix: Add tests (diff)
downloadnixpkgs-150217c1ac10fbef93e03694f6955029249c9aa4.tar.gz
lib.removePrefix: Optimise
Diffstat (limited to 'lib')
-rw-r--r--lib/strings.nix4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/strings.nix b/lib/strings.nix
index 1eb6cf9c1afb..df891c899887 100644
--- a/lib/strings.nix
+++ b/lib/strings.nix
@@ -629,10 +629,10 @@ rec {
This behavior is deprecated and will throw an error in the future.''
(let
preLen = stringLength prefix;
- sLen = stringLength str;
in
if substring 0 preLen str == prefix then
- substring preLen (sLen - preLen) str
+ # -1 will take the string until the end
+ substring preLen (-1) str
else
str);