[Rivet-svn] r2069 - trunk/src

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Wed Nov 18 22:12:03 GMT 2009


Author: buckley
Date: Wed Nov 18 22:12:03 2009
New Revision: 2069

Log:
Removing accidental double-cloning of projections in ProjectionHandler

Modified:
   trunk/src/ProjectionHandler.cc

Modified: trunk/src/ProjectionHandler.cc
==============================================================================
--- trunk/src/ProjectionHandler.cc	Wed Nov 18 15:02:36 2009	(r2068)
+++ trunk/src/ProjectionHandler.cc	Wed Nov 18 22:12:03 2009	(r2069)
@@ -12,6 +12,8 @@
   ProjectionHandler* ProjectionHandler::_instance = 0;
 
 
+  //int Log_TRACE = Log::INFO;
+
 
   ProjectionHandler* ProjectionHandler::create() {
     if (!_instance) {
@@ -93,7 +95,7 @@
   const Projection* ProjectionHandler::_clone(const ProjectionApplier& parent, 
                                               const Projection& proj)
   {
-    // All is well so far, so we clone a new copy of the passed projection on the heap
+    // Clone a new copy of the passed projection on the heap
     getLog() << Log::TRACE << "Cloning projection " << proj.name() << " from " << &proj << endl;
     const Projection* newproj = proj.clone();
     getLog() << Log::TRACE << "Cloned projection " << proj.name() << " at " << newproj << endl;
@@ -121,23 +123,7 @@
                                                  const Projection& proj, 
                                                  const string& name)
   {
-    // All is well so far, so we clone a new copy of the passed projection on the heap
-    getLog() << Log::TRACE << "Cloning projection " << proj.name() << " from " << &proj << endl;
-    const Projection* newproj = proj.clone();
-    getLog() << Log::TRACE << "Cloned projection " << proj.name() << " at " << newproj << endl;
-
-    // Copy all the child ProjHandles when cloning, since otherwise links to "stack parents" 
-    // will be generated by their children, without any connection to the cloned parent
-    if (&proj != newproj) {
-      NamedProjsMap::const_iterator nps = _namedprojs.find(&proj);
-      if (nps != _namedprojs.end()) {
-        getLog() << Log::TRACE << "Cloning registered projections list: " 
-                 << &proj << " -> " << newproj << endl;
-        _namedprojs[newproj] = nps->second;
-      }
-    }
-    
-    ProjHandle ph(newproj);
+    ProjHandle ph(&proj);
     getLog() << Log::TRACE << "Registering new projection at " << ph << endl;
 
     // Add the passed Projection to _projs
@@ -162,7 +148,7 @@
     // Compare to ALL projections via _projs collection
     getLog() << Log::TRACE << "Comparing " << &proj 
              << " with " << _projs.size()
-             << " registered projections" <<  endl;
+             << " registered projection" << (_projs.size() == 1 ? "" : "s") <<  endl;
     foreach (const ProjHandle& ph, _projs) {
       // Make sure the concrete types match, using RTTI.
       const std::type_info& regtype = typeid(*ph);
@@ -173,10 +159,10 @@
       
       // Test for semantic match
       if (pcmp(*ph, proj) != PCmp::EQUIVALENT) {
-        getLog() << Log::TRACE << "Projections at " 
+        getLog() << Log::TRACE << "Projections at "
                  << &proj << " and " << ph << " are not equivalent" << endl;
       } else {
-        getLog() << Log::TRACE << "MATCH! Projections at " 
+        getLog() << Log::TRACE << "MATCH! Projections at "
                  << &proj << " and " << ph << " are equivalent" << endl;
         return ph.get();
       }


More information about the Rivet-svn mailing list