From 75634202377e07e6fc4bf226caa9c948fc23c962 Mon Sep 17 00:00:00 2001
From: scott snyder <sss@karma>
Date: Tue, 4 Aug 2020 10:14:28 -0400
Subject: [PATCH] AthenaKernel: Use static_cast to DataBucket.

A DataProxy holds a pointer to a DataObject.
When we were doing a casting operation from a DataProxy,
we were using dynamic_cast to convert from DataObject to DataBucketBase.
Nowadays, though, this DataObject is always an instance of a DataBucket.
So do a static_cast instead.
This speeds up the casting operation.
---
 .../AthenaKernel/DataBucketBase.icc           |  1 -
 .../AthenaKernel/StorableConversions.h        | 21 ++++++-------------
 2 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/Control/AthenaKernel/AthenaKernel/DataBucketBase.icc b/Control/AthenaKernel/AthenaKernel/DataBucketBase.icc
index 865698c33fcc..8b1302bfc19d 100755
--- a/Control/AthenaKernel/AthenaKernel/DataBucketBase.icc
+++ b/Control/AthenaKernel/AthenaKernel/DataBucketBase.icc
@@ -54,4 +54,3 @@ void* DataBucketBase::cast (CLID /*clid*/,
 {
   return cast (tinfo, irt, isConst);
 }
-
diff --git a/Control/AthenaKernel/AthenaKernel/StorableConversions.h b/Control/AthenaKernel/AthenaKernel/StorableConversions.h
index 2c53f9d97205..a2d208e7e08b 100755
--- a/Control/AthenaKernel/AthenaKernel/StorableConversions.h
+++ b/Control/AthenaKernel/AthenaKernel/StorableConversions.h
@@ -1,7 +1,7 @@
 // This file's extension implies that it's C, but it's really -*- C++ -*-.
 
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef ATHENAKERNEL_STORABLECONVERSIONS_H
@@ -186,7 +186,6 @@ namespace SG {
                      bool isConst /*= true*/)
   {
     typedef typename std::remove_const<T>::type T_nc;
-    typedef typename DataBucketTrait<T_nc>::type bucket_t;
     DataBucketTrait<T_nc>::init();
 
     //check inputs
@@ -200,19 +199,11 @@ namespace SG {
     }
 
     // get T* from DataBucket:
-    SG::DataBucket<T_nc>* bucketPtr = dynamic_cast<bucket_t*>(pDObj);
-    bool success(0 != bucketPtr);
-    if (success)
-      pTrans = *bucketPtr;
-    else {
-      // Try to use BaseInfo information to convert pointers.
-      DataBucketBase* b = dynamic_cast<DataBucketBase*>(pDObj);
-      if (b) {
-        pTrans = b->template cast<T_nc> (irt, isConst);
-        if (pTrans)
-          success = true;
-      }
-    }
+    // All objects in the event store nowadays are instances
+    // of DataBucket, so just do a static_cast.
+    DataBucketBase* b = static_cast<DataBucketBase*>(pDObj);
+    pTrans = b->template cast<T_nc> (irt, isConst);
+    bool success = pTrans != nullptr;
 
 #ifndef NDEBUG
     if (!quiet && !success) {
-- 
GitLab