From 6c2439daff5d83700e62cadee27fce298e5705cb Mon Sep 17 00:00:00 2001
From: scott snyder <sss@karma>
Date: Tue, 23 Jun 2020 17:04:35 +0200
Subject: [PATCH] EventCommonTPCnv: Fix cppcheck warnings.

Avoid some redundant map lookups.
---
 Event/EventCommonTPCnv/src/INav4MomAssocsCnv_p1.cxx | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/Event/EventCommonTPCnv/src/INav4MomAssocsCnv_p1.cxx b/Event/EventCommonTPCnv/src/INav4MomAssocsCnv_p1.cxx
index 284bb88c386a..6a98eff82a3b 100755
--- a/Event/EventCommonTPCnv/src/INav4MomAssocsCnv_p1.cxx
+++ b/Event/EventCommonTPCnv/src/INav4MomAssocsCnv_p1.cxx
@@ -72,9 +72,10 @@ INav4MomAssocsCnv_p1::persToTrans( const INav4MomAssocs_p1* persObj,
     log << MSG::DEBUG << "\tassLink=" << assKey << ", " << assLink.second << endmsg;
 
     if ( collections.find(objKey) == collections.end() ) {
+      const INavigable4MomentumCollection* coll = nullptr;
       collections[objKey] = 0;
-      if ( m_storeGate->retrieve( collections[objKey], objKey ).isFailure() ||
-           0 == collections[objKey] ) {
+      if ( m_storeGate->retrieve( coll, objKey ).isFailure() ||
+           nullptr == coll ) {
         log << MSG::ERROR
             << "Could not retrieve INavigable4MomentumCollection at : "
             << objKey
@@ -86,12 +87,13 @@ INav4MomAssocsCnv_p1::persToTrans( const INav4MomAssocs_p1* persObj,
             << objKey
             << endmsg;
       }
+      collections[objKey] = coll;
     }
 
     if ( collections.find(assKey) == collections.end() ) {
-      collections[assKey] = 0;
-      if ( m_storeGate->retrieve( collections[assKey], assKey ).isFailure() ||
-           0 == collections[assKey] ) {
+      const INavigable4MomentumCollection* coll = nullptr;
+      if ( m_storeGate->retrieve( coll, assKey ).isFailure() ||
+           nullptr == coll ) {
         log << MSG::ERROR
             << "Could not retrieve INavigable4MomentumCollection at : "
             << assKey
@@ -103,6 +105,7 @@ INav4MomAssocsCnv_p1::persToTrans( const INav4MomAssocs_p1* persObj,
             << assKey
             << endmsg;
       }
+      collections[assKey] = coll;
     }
 
     transObj->addAssociation( collections[objKey], objLink.second,
-- 
GitLab