From a6b86228624d535cde684c3063e38e02ffaa296f Mon Sep 17 00:00:00 2001 From: Milian Wolff Date: Wed, 21 May 2014 21:41:09 +0200 Subject: [PATCH] Preallocate trace buffer once. --- malloctrace.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/malloctrace.cpp b/malloctrace.cpp index c76c62c..54533c7 100644 --- a/malloctrace.cpp +++ b/malloctrace.cpp @@ -87,6 +87,9 @@ void trace(const int skip = 2) { traceBuffer.clear(); + const size_t MAX_TRACE_SIZE = 64; + traceBuffer.reserve(MAX_TRACE_SIZE); + unw_context_t uc; unw_getcontext (&uc); @@ -100,7 +103,6 @@ void trace(const int skip = 2) } } - const size_t MAX_TRACE_SIZE = 64; while (unw_step(&cursor) > 0 && traceBuffer.size() < MAX_TRACE_SIZE) { unw_word_t ip; -- 2.7.4