1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-08 02:43:54 +02:00

Merge pull request #9747 from awakesecurity/mz/fix-quadratic-splitString

Fix performance of builtins.substring for empty substrings
This commit is contained in:
Robert Hensing 2024-01-16 12:18:59 +01:00 committed by GitHub
commit b2deff1947
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 3 deletions

View file

@ -0,0 +1 @@
"okay"

View file

@ -0,0 +1,11 @@
with builtins;
let
s = "${builtins.derivation { name = "test"; builder = "/bin/sh"; system = "x86_64-linux"; }}";
in
if getContext s == getContext "${substring 0 0 s + unsafeDiscardStringContext s}"
then "okay"
else throw "empty substring should preserve context"