]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliFMDFloatMap.cxx
Added option to reuse list in AliESDEvent, avoid delete/new whenever possible in...
[u/mrichter/AliRoot.git] / STEER / AliFMDFloatMap.cxx
index 5be6487bb53a4c4194687136c7dca303004a226d..86967661e0a629b446fb8f9a7cc6d177bacf08a3 100755 (executable)
@@ -71,13 +71,19 @@ AliFMDFloatMap::operator=(const AliFMDFloatMap& other)
 {
   // Assignment operator 
   if(&other != this){
-    fMaxDetectors = other.fMaxDetectors;
-    fMaxRings     = other.fMaxRings;
-    fMaxSectors   = other.fMaxSectors;
-    fMaxStrips    = other.fMaxStrips;
-    fTotal        = fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips;
-    if (fData) delete [] fData;
-    fData = new Float_t[fTotal];
+    if(fMaxDetectors!= other.fMaxDetectors||
+       fMaxRings    != other.fMaxRings||
+       fMaxSectors  != other.fMaxSectors||
+       fMaxStrips   != other.fMaxStrips){
+      // allocate new memory only if the array size is different....
+      fMaxDetectors = other.fMaxDetectors;
+      fMaxRings     = other.fMaxRings;
+      fMaxSectors   = other.fMaxSectors;
+      fMaxStrips    = other.fMaxStrips;
+      fTotal        = fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips;
+      if (fData) delete [] fData;
+      fData = new Float_t[fTotal];
+    }
     for (Int_t i = 0; i < fTotal; i++) fData[i] = other.fData[i];
   }
   return *this;