From acf1e51a284c5e13a44ca7d60328cd971afcaf58 Mon Sep 17 00:00:00 2001 From: elsid Date: Fri, 26 Apr 2024 15:31:29 +0200 Subject: [PATCH] Call getUserPointer only for not nullptr collision object nullptr can't have user pointer anyway so it saves a lookup in the unordered_map. --- apps/openmw/mwphysics/mtphysics.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwphysics/mtphysics.cpp b/apps/openmw/mwphysics/mtphysics.cpp index 52b96d9d13..341d1a202c 100644 --- a/apps/openmw/mwphysics/mtphysics.cpp +++ b/apps/openmw/mwphysics/mtphysics.cpp @@ -275,10 +275,13 @@ namespace if (mAdvanceSimulation) { MWWorld::Ptr standingOn; - auto* ptrHolder - = static_cast(scheduler->getUserPointer(frameData.mStandingOn)); - if (ptrHolder) - standingOn = ptrHolder->getPtr(); + if (frameData.mStandingOn != nullptr) + { + auto* const ptrHolder + = static_cast(scheduler->getUserPointer(frameData.mStandingOn)); + if (ptrHolder != nullptr) + standingOn = ptrHolder->getPtr(); + } actor->setStandingOnPtr(standingOn); // the "on ground" state of an actor might have been updated by a traceDown, don't overwrite the // change