aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/value.hh
diff options
context:
space:
mode:
authorpennae <github@quasiparticle.net>2021-12-27 02:04:49 +0100
committerpennae <github@quasiparticle.net>2022-01-12 10:07:21 +0100
commit5838354d342f1cdd09da7099e86123b36ecec409 (patch)
treeebb68fd2ba7e9b29a10b36a90429b94c8efa1515 /src/libexpr/value.hh
parent26a8b220eb7470e132b9bcedb94b58492cdd786f (diff)
optimize ExprConcatStrings::eval
constructing an ostringstream for non-string concats (like integer addition) is a small constant cost that we can avoid. for string concats we can keep all the string temporaries we get from coerceToString and concatenate them in one go, which saves a lot of intermediate temporaries and copies in ostringstream. we can also avoid copying the concatenated string again by directly allocating it in GC memory and moving ownership of the concatenated string into the target value. saves about 2% on system eval. before: Benchmark 1: nix eval --raw --impure --expr 'with import <nixpkgs/nixos> {}; system' Time (mean ± σ): 2.837 s ± 0.031 s [User: 2.562 s, System: 0.191 s] Range (min … max): 2.796 s … 2.892 s 20 runs after: Benchmark 1: nix eval --raw --impure --expr 'with import <nixpkgs/nixos> {}; system' Time (mean ± σ): 2.790 s ± 0.035 s [User: 2.532 s, System: 0.187 s] Range (min … max): 2.722 s … 2.836 s 20 runs
Diffstat (limited to 'src/libexpr/value.hh')
-rw-r--r--src/libexpr/value.hh2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/libexpr/value.hh b/src/libexpr/value.hh
index 7d007ebdc..1896c7563 100644
--- a/src/libexpr/value.hh
+++ b/src/libexpr/value.hh
@@ -241,6 +241,8 @@ public:
void mkString(std::string_view s, const PathSet & context);
+ void mkStringMove(const char * s, const PathSet & context);
+
inline void mkString(const Symbol & s)
{
mkString(((const std::string &) s).c_str());