From: Zygo Blaxell Date: Thu, 13 Feb 2025 01:10:12 +0000 (-0500) Subject: trace: avoid one copy in every trace function X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ae58401d53698714dcede2fc2c3879f3a11f5ade;p=bees trace: avoid one copy in every trace function While investigating https://github.com/Zygo/bees/issues/282 I noticed that we're doing at least one unnecessary extra copy of the functor in BEESTRACE. Get rid of it with a const reference. Signed-off-by: Zygo Blaxell --- diff --git a/src/bees-trace.cc b/src/bees-trace.cc index 5e585323..81b70d57 100644 --- a/src/bees-trace.cc +++ b/src/bees-trace.cc @@ -49,7 +49,7 @@ BeesTracer::~BeesTracer() } } -BeesTracer::BeesTracer(function f, bool silent) : +BeesTracer::BeesTracer(const function &f, bool silent) : m_func(f) { m_next_tracer = tl_next_tracer; diff --git a/src/bees.h b/src/bees.h index 10ed7f63..888f91ed 100644 --- a/src/bees.h +++ b/src/bees.h @@ -193,7 +193,7 @@ class BeesTracer { thread_local static bool tl_silent; thread_local static bool tl_first; public: - BeesTracer(function f, bool silent = false); + BeesTracer(const function &f, bool silent = false); ~BeesTracer(); static void trace_now(); static bool get_silent();