aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-01-06 12:43:07 +0100
committerEelco Dolstra <edolstra@gmail.com>2020-01-06 12:43:07 +0100
commit1dc29df1d384e90d0604e1b21150cfc93b58ff56 (patch)
treec48f2e772fa5d01eda24f1bd165380f2534dd25a /src/libexpr
parentc7866733d7ce2836fbb43de90dd64d17b0d20753 (diff)
parent0486e87791f0d50f98ccd46c56f32ecc4e1bc79c (diff)
Merge remote-tracking branch 'origin/master' into flakes
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/eval.cc4
-rw-r--r--src/libexpr/function-trace.cc17
-rw-r--r--src/libexpr/function-trace.hh14
3 files changed, 20 insertions, 15 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index cddbce20d..427a6f299 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -1146,9 +1146,7 @@ void EvalState::callPrimOp(Value & fun, Value & arg, Value & v, const Pos & pos)
void EvalState::callFunction(Value & fun, Value & arg, Value & v, const Pos & pos)
{
- std::unique_ptr<FunctionCallTrace> trace;
- if (evalSettings.traceFunctionCalls)
- trace = std::make_unique<FunctionCallTrace>(pos);
+ auto trace = evalSettings.traceFunctionCalls ? std::make_unique<FunctionCallTrace>(pos) : nullptr;
forceValue(fun, pos);
diff --git a/src/libexpr/function-trace.cc b/src/libexpr/function-trace.cc
new file mode 100644
index 000000000..af1486f78
--- /dev/null
+++ b/src/libexpr/function-trace.cc
@@ -0,0 +1,17 @@
+#include "function-trace.hh"
+
+namespace nix {
+
+FunctionCallTrace::FunctionCallTrace(const Pos & pos) : pos(pos) {
+ auto duration = std::chrono::high_resolution_clock::now().time_since_epoch();
+ auto ns = std::chrono::duration_cast<std::chrono::nanoseconds>(duration);
+ printMsg(lvlInfo, "function-trace entered %1% at %2%", pos, ns.count());
+}
+
+FunctionCallTrace::~FunctionCallTrace() {
+ auto duration = std::chrono::high_resolution_clock::now().time_since_epoch();
+ auto ns = std::chrono::duration_cast<std::chrono::nanoseconds>(duration);
+ printMsg(lvlInfo, "function-trace exited %1% at %2%", pos, ns.count());
+}
+
+}
diff --git a/src/libexpr/function-trace.hh b/src/libexpr/function-trace.hh
index 2c39b7430..472f2045e 100644
--- a/src/libexpr/function-trace.hh
+++ b/src/libexpr/function-trace.hh
@@ -9,17 +9,7 @@ namespace nix {
struct FunctionCallTrace
{
const Pos & pos;
-
- FunctionCallTrace(const Pos & pos) : pos(pos) {
- auto duration = std::chrono::high_resolution_clock::now().time_since_epoch();
- auto ns = std::chrono::duration_cast<std::chrono::nanoseconds>(duration);
- printMsg(lvlInfo, "function-trace entered %1% at %2%", pos, ns.count());
- }
-
- ~FunctionCallTrace() {
- auto duration = std::chrono::high_resolution_clock::now().time_since_epoch();
- auto ns = std::chrono::duration_cast<std::chrono::nanoseconds>(duration);
- printMsg(lvlInfo, "function-trace exited %1% at %2%", pos, ns.count());
- }
+ FunctionCallTrace(const Pos & pos);
+ ~FunctionCallTrace();
};
}