From b5447f9c331cf5367ac7a35f57e5099c5c100b73 Mon Sep 17 00:00:00 2001 From: Volker Krause Date: Tue, 12 Jan 2016 10:40:43 +0100 Subject: QtConcurrent: Avoid an allocation in ExceptionHolder if there is no exception to store. Qt3D hits this several times per frame. Change-Id: Iaadcfbe79f146bd73b36f01325580dc24a10225c Reviewed-by: Marc Mutz --- src/corelib/thread/qexception.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/corelib/thread') diff --git a/src/corelib/thread/qexception.cpp b/src/corelib/thread/qexception.cpp index 04a03b8623..cecd69c273 100644 --- a/src/corelib/thread/qexception.cpp +++ b/src/corelib/thread/qexception.cpp @@ -165,7 +165,7 @@ public: }; ExceptionHolder::ExceptionHolder(QException *exception) -: base(new Base(exception)) {} +: base(exception ? new Base(exception) : Q_NULLPTR) {} ExceptionHolder::ExceptionHolder(const ExceptionHolder &other) : base(other.base) @@ -181,6 +181,8 @@ ExceptionHolder::~ExceptionHolder() QException *ExceptionHolder::exception() const { + if (!base) + return Q_NULLPTR; return base->exception; } -- cgit v1.2.3