diff --git a/core/base/inc/TBuffer.h b/core/base/inc/TBuffer.h index 12c14d3e52c69..e383bb738d672 100644 --- a/core/base/inc/TBuffer.h +++ b/core/base/inc/TBuffer.h @@ -64,10 +64,10 @@ class TBuffer : public TObject { void operator=(const TBuffer &) = delete; Int_t Read(const char *name) override { return TObject::Read(name); } - Int_t Write(const char *name, Int_t opt, Int_t bufs) override - { return TObject::Write(name, opt, bufs); } - Int_t Write(const char *name, Int_t opt, Int_t bufs) const override - { return TObject::Write(name, opt, bufs); } + Int_t Write(const char *name, Int_t opt, Int_t bufsize) override + { return TObject::Write(name, opt, bufsize); } + Int_t Write(const char *name, Int_t opt, Int_t bufsize) const override + { return TObject::Write(name, opt, bufsize); } public: enum EMode { kRead = 0, kWrite = 1 }; @@ -78,8 +78,8 @@ class TBuffer : public TObject { enum { kInitialSize = 1024, kMinimalSize = 128 }; TBuffer(EMode mode); - TBuffer(EMode mode, Int_t bufsiz); - TBuffer(EMode mode, Int_t bufsiz, void *buf, Bool_t adopt = kTRUE, ReAllocCharFun_t reallocfunc = nullptr); + TBuffer(EMode mode, Int_t bufsize); + TBuffer(EMode mode, Int_t bufsize, void *buf, Bool_t adopt = kTRUE, ReAllocCharFun_t reallocfunc = nullptr); virtual ~TBuffer(); Int_t GetBufferVersion() const { return fVersion; } @@ -87,7 +87,7 @@ class TBuffer : public TObject { Bool_t IsWriting() const { return (fMode & kWrite) != 0; } void SetReadMode(); void SetWriteMode(); - void SetBuffer(void *buf, UInt_t bufsiz = 0, Bool_t adopt = kTRUE, ReAllocCharFun_t reallocfunc = nullptr); + void SetBuffer(void *buf, UInt_t bufsize = 0, Bool_t adopt = kTRUE, ReAllocCharFun_t reallocfunc = nullptr); ReAllocCharFun_t GetReAllocFunc() const; void SetReAllocFunc(ReAllocCharFun_t reallocfunc = nullptr); void SetBufferOffset(Int_t offset = 0) { fBufCur = fBuffer+offset; } diff --git a/core/base/src/TBuffer.cxx b/core/base/src/TBuffer.cxx index a5e1b96a65961..6cb2bc3651b14 100644 --- a/core/base/src/TBuffer.cxx +++ b/core/base/src/TBuffer.cxx @@ -70,12 +70,12 @@ TBuffer::TBuffer(EMode mode) /// Create an I/O buffer object. Mode should be either TBuffer::kRead or /// TBuffer::kWrite. -TBuffer::TBuffer(EMode mode, Int_t bufsiz) +TBuffer::TBuffer(EMode mode, Int_t bufsize) { - if (bufsiz < 0) - Fatal("TBuffer","Request to create a buffer with a negative size, likely due to an integer overflow: 0x%x for a max of 0x%x.", bufsiz, kMaxBufferSize); - if (bufsiz < kMinimalSize) bufsiz = kMinimalSize; - fBufSize = bufsiz; + if (bufsize < 0) + Fatal("TBuffer","Request to create a buffer with a negative size, likely due to an integer overflow: 0x%x for a max of 0x%x.", bufsize, kMaxBufferSize); + if (bufsize < kMinimalSize) bufsize = kMinimalSize; + fBufSize = bufsize; fMode = mode; fVersion = 0; fParent = nullptr; @@ -101,11 +101,11 @@ TBuffer::TBuffer(EMode mode, Int_t bufsiz) /// is provided, a Fatal error will be issued if the Buffer attempts to /// expand. -TBuffer::TBuffer(EMode mode, Int_t bufsiz, void *buf, Bool_t adopt, ReAllocCharFun_t reallocfunc) +TBuffer::TBuffer(EMode mode, Int_t bufsize, void *buf, Bool_t adopt, ReAllocCharFun_t reallocfunc) { - if (bufsiz < 0) - Fatal("TBuffer","Request to create a buffer with a negative size, likely due to an integer overflow: 0x%x for a max of 0x%x.", bufsiz, kMaxBufferSize); - fBufSize = bufsiz; + if (bufsize < 0) + Fatal("TBuffer","Request to create a buffer with a negative size, likely due to an integer overflow: 0x%x for a max of 0x%x.", bufsize, kMaxBufferSize); + fBufSize = bufsize; fMode = mode; fVersion = 0; fParent = nullptr; @@ -283,7 +283,7 @@ ReAllocCharFun_t TBuffer::GetReAllocFunc() const /// Set which memory reallocation method to use. If reallocafunc is null, /// reset it to the default value (TStorage::ReAlloc) -void TBuffer::SetReAllocFunc(ReAllocCharFun_t reallocfunc ) +void TBuffer::SetReAllocFunc(ReAllocCharFun_t reallocfunc) { if (reallocfunc) { fReAllocFunc = reallocfunc; diff --git a/core/cont/src/TCollection.cxx b/core/cont/src/TCollection.cxx index 6d69f092bc399..80f1a0aded352 100644 --- a/core/cont/src/TCollection.cxx +++ b/core/cont/src/TCollection.cxx @@ -676,17 +676,17 @@ void TCollection::Streamer(TBuffer &b) /// objects using a single key specify a name and set option to /// TObject::kSingleKey (i.e. 1). -Int_t TCollection::Write(const char *name, Int_t option, Int_t bsize) const +Int_t TCollection::Write(const char *name, Int_t option, Int_t bufsize) const { if ((option & kSingleKey)) { - return TObject::Write(name, option, bsize); + return TObject::Write(name, option, bufsize); } else { option &= ~kSingleKey; Int_t nbytes = 0; TIter next(this); TObject *obj; while ((obj = next())) { - nbytes += obj->Write(name, option, bsize); + nbytes += obj->Write(name, option, bufsize); } return nbytes; } @@ -700,9 +700,9 @@ Int_t TCollection::Write(const char *name, Int_t option, Int_t bsize) const /// objects using a single key specify a name and set option to /// TObject::kSingleKey (i.e. 1). -Int_t TCollection::Write(const char *name, Int_t option, Int_t bsize) +Int_t TCollection::Write(const char *name, Int_t option, Int_t bufsize) { - return ((const TCollection*)this)->Write(name,option,bsize); + return ((const TCollection*)this)->Write(name,option,bufsize); } //////////////////////////////////////////////////////////////////////////////// diff --git a/core/cont/src/TMap.cxx b/core/cont/src/TMap.cxx index f4631c8bb0aef..89abc3e1a45e4 100644 --- a/core/cont/src/TMap.cxx +++ b/core/cont/src/TMap.cxx @@ -402,10 +402,10 @@ void TMap::Streamer(TBuffer &b) /// objects using a single key specify a name and set option to /// TObject::kSingleKey (i.e. 1). -Int_t TMap::Write(const char *name, Int_t option, Int_t bsize) const +Int_t TMap::Write(const char *name, Int_t option, Int_t bufsize) const { if ((option & kSingleKey)) { - return TObject::Write(name, option, bsize); + return TObject::Write(name, option, bufsize); } else { option &= ~kSingleKey; Int_t nbytes = 0; @@ -413,9 +413,9 @@ Int_t TMap::Write(const char *name, Int_t option, Int_t bsize) const TPair *a; while ((a = (TPair*) next())) { if (a->Key()) - nbytes += a->Key()->Write(name, option, bsize); + nbytes += a->Key()->Write(name, option, bufsize); if (a->Value()) - nbytes += a->Value()->Write(name, option, bsize); + nbytes += a->Value()->Write(name, option, bufsize); } return nbytes; } @@ -429,9 +429,9 @@ Int_t TMap::Write(const char *name, Int_t option, Int_t bsize) const /// objects using a single key specify a name and set option to /// TObject::kSingleKey (i.e. 1). -Int_t TMap::Write(const char *name, Int_t option, Int_t bsize) +Int_t TMap::Write(const char *name, Int_t option, Int_t bufsize) { - return ((const TMap*)this)->Write(name,option,bsize); + return ((const TMap*)this)->Write(name,option,bufsize); } /** \class TPair diff --git a/graf3d/g3d/inc/TXTRU.h b/graf3d/g3d/inc/TXTRU.h index 4fefcc3329ced..0a763127a21c0 100644 --- a/graf3d/g3d/inc/TXTRU.h +++ b/graf3d/g3d/inc/TXTRU.h @@ -87,7 +87,7 @@ class TXTRU : public TShape { private: void DumpPoints(int npoints, float *pointbuff) const; void DumpSegments(int nsegments, int *segbuff) const; - void DumpPolygons(int npolygons, int *polybuff, int buffsize) const; + void DumpPolygons(int npolygons, int *polybuff, int bufsize) const; ClassDefOverride(TXTRU,1) //TXTRU shape }; diff --git a/graf3d/g3d/src/TXTRU.cxx b/graf3d/g3d/src/TXTRU.cxx index 17585b6356ed1..82ce1f9b8e80a 100644 --- a/graf3d/g3d/src/TXTRU.cxx +++ b/graf3d/g3d/src/TXTRU.cxx @@ -709,7 +709,7 @@ void TXTRU::DumpSegments(int nsegments, int *segbuff) const //////////////////////////////////////////////////////////////////////////////// /// Dump the derived polygon info for visual inspection -void TXTRU::DumpPolygons(int npolygons, int *polybuff, int buffsize) const +void TXTRU::DumpPolygons(int npolygons, int *polybuff, int bufsize) const { std::cout << "TXTRU::DumpPolygons - " << npolygons << " polygons" << std::endl; int ioff = 0; @@ -729,7 +729,7 @@ void TXTRU::DumpPolygons(int npolygons, int *polybuff, int buffsize) const } std::cout << polybuff[ioff++] << ")" << std::endl; } - std::cout << " buffer size " << buffsize << " last used " << --ioff << std::endl; + std::cout << " buffer size " << bufsize << " last used " << --ioff << std::endl; } //////////////////////////////////////////////////////////////////////////////// diff --git a/graf3d/gl/src/TGLOutput.cxx b/graf3d/gl/src/TGLOutput.cxx index 88c80df953efd..aae123cd8e8f7 100644 --- a/graf3d/gl/src/TGLOutput.cxx +++ b/graf3d/gl/src/TGLOutput.cxx @@ -104,16 +104,16 @@ Bool_t TGLOutput::CapturePostscript(TGLViewer & viewer, EFormat format, const ch assert(kFALSE); return kFALSE; } - Int_t buffsize = 0, state = GL2PS_OVERFLOW; + Int_t bufsize = 0, state = GL2PS_OVERFLOW; viewer.DoDraw(); viewer.fIsPrinting = kTRUE; while (state == GL2PS_OVERFLOW) { - buffsize += 1024*1024; + bufsize += 1024*1024; gl2psBeginPage ("ROOT Scene Graph", "ROOT", nullptr, gl2psFormat, gl2psSort, GL2PS_USE_CURRENT_VIEWPORT | GL2PS_SILENT | GL2PS_BEST_ROOT | GL2PS_OCCLUSION_CULL | 0, GL_RGBA, 0, nullptr,0, 0, 0, - buffsize, output, nullptr); + bufsize, output, nullptr); viewer.DoDraw(); state = gl2psEndPage(); std::cout << "."; @@ -210,17 +210,17 @@ void TGLOutput::Capture(TGLViewer & viewer) Int_t gl2psFormat = GL2PS_EPS; Int_t gl2psSort = GL2PS_BSP_SORT; - Int_t buffsize = 0, state = GL2PS_OVERFLOW; + Int_t bufsize = 0, state = GL2PS_OVERFLOW; viewer.DoDraw(); viewer.fIsPrinting = kTRUE; while (state == GL2PS_OVERFLOW) { - buffsize += 1024*1024; + bufsize += 1024*1024; gl2psBeginPage ("ROOT Scene Graph", "ROOT", nullptr, gl2psFormat, gl2psSort, GL2PS_USE_CURRENT_VIEWPORT | GL2PS_SILENT | GL2PS_BEST_ROOT | GL2PS_OCCLUSION_CULL | 0, GL_RGBA, 0, nullptr,0, 0, 0, - buffsize, output, nullptr); + bufsize, output, nullptr); viewer.DoDraw(); state = gl2psEndPage(); std::cout << "."; diff --git a/graf3d/gl/src/TGLPlotPainter.cxx b/graf3d/gl/src/TGLPlotPainter.cxx index 0d60cb1d31bab..952be70a19e0c 100644 --- a/graf3d/gl/src/TGLPlotPainter.cxx +++ b/graf3d/gl/src/TGLPlotPainter.cxx @@ -243,7 +243,7 @@ void TGLPlotPainter::PrintPlot()const Int_t gl2psFormat = GL2PS_EPS; Int_t gl2psSort = GL2PS_BSP_SORT; - Int_t buffsize = 0; + Int_t bufsize = 0; Int_t state = GL2PS_OVERFLOW; GLint gl2psoption = GL2PS_USE_CURRENT_VIEWPORT | GL2PS_SILENT | @@ -252,11 +252,11 @@ void TGLPlotPainter::PrintPlot()const 0; while (state == GL2PS_OVERFLOW) { - buffsize += 1024*1024; + bufsize += 1024*1024; gl2psBeginPage ("ROOT Scene Graph", "ROOT", nullptr, gl2psFormat, gl2psSort, gl2psoption, GL_RGBA, 0, nullptr,0, 0, 0, - buffsize, output, nullptr); + bufsize, output, nullptr); DrawPlot(); state = gl2psEndPage(); } diff --git a/hist/hist/inc/TH1.h b/hist/hist/inc/TH1.h index de6c8c1cac1b9..75bbbcee6c463 100644 --- a/hist/hist/inc/TH1.h +++ b/hist/hist/inc/TH1.h @@ -626,13 +626,13 @@ class TH1 : public TNamed, public TAttLine, public TAttFill, public TAttMarker { const Double_t *zBins); virtual void SetBinsLength(Int_t = -1) { } //redefined in derived classes virtual void SetBinErrorOption(EBinErrorOpt type) { fBinStatErrOpt = type; } - virtual void SetBuffer(Int_t buffersize, Option_t *option=""); + virtual void SetBuffer(Int_t bufsize, Option_t *option=""); virtual UInt_t SetCanExtend(UInt_t extendBitMask); virtual void SetContent(const Double_t *content); virtual void SetContour(Int_t nlevels, const Double_t *levels = nullptr); virtual void SetContourLevel(Int_t level, Double_t value); virtual void SetColors(Color_t linecolor = -1, Color_t markercolor = -1, Color_t fillcolor = -1); - static void SetDefaultBufferSize(Int_t buffersize=1000); + static void SetDefaultBufferSize(Int_t bufsize=1000); static void SetDefaultSumw2(Bool_t sumw2=kTRUE); virtual void SetDirectory(TDirectory *dir); virtual void SetEntries(Double_t n) { fEntries = n; } diff --git a/hist/hist/inc/TProfile.h b/hist/hist/inc/TProfile.h index 724746de07111..2149b1b478aea 100644 --- a/hist/hist/inc/TProfile.h +++ b/hist/hist/inc/TProfile.h @@ -131,7 +131,7 @@ class TProfile : public TH1D { void SetBins(Int_t nbins, Double_t xmin, Double_t xmax) override; void SetBins(Int_t nx, const Double_t *xbins) override; void SetBinsLength(Int_t n=-1) override; - void SetBuffer(Int_t buffersize, Option_t *option="") override; + void SetBuffer(Int_t bufsize, Option_t *option="") override; virtual void SetErrorOption(Option_t *option=""); // *MENU* void Sumw2(Bool_t flag = kTRUE) override; diff --git a/hist/hist/inc/TProfile2D.h b/hist/hist/inc/TProfile2D.h index ac498cf705251..f7a0edc755600 100644 --- a/hist/hist/inc/TProfile2D.h +++ b/hist/hist/inc/TProfile2D.h @@ -145,7 +145,7 @@ class TProfile2D : public TH2D { void SetBins(Int_t nbinsx, Double_t xmin, Double_t xmax, Int_t nbinsy, Double_t ymin, Double_t ymax) override; void SetBins(Int_t nx, const Double_t *xBins, Int_t ny, const Double_t *yBins) override; void SetBinsLength(Int_t n=-1) override; - void SetBuffer(Int_t buffersize, Option_t *option="") override; + void SetBuffer(Int_t bufsize, Option_t *option="") override; virtual void SetErrorOption(Option_t *option=""); // *MENU* void Sumw2(Bool_t flag = kTRUE) override; Double_t GetNumberOfBins() { return fBinEntries.GetSize(); } diff --git a/hist/hist/inc/TProfile3D.h b/hist/hist/inc/TProfile3D.h index 2eab0fde45bb7..4fe600436ff10 100644 --- a/hist/hist/inc/TProfile3D.h +++ b/hist/hist/inc/TProfile3D.h @@ -143,7 +143,7 @@ class TProfile3D : public TH3D { void SetBins(Int_t nx, const Double_t *xBins, Int_t ny, const Double_t * yBins, Int_t nz, const Double_t *zBins) override; void SetBinsLength(Int_t n=-1) override; - void SetBuffer(Int_t buffersize, Option_t *opt="") override; + void SetBuffer(Int_t bufsize, Option_t *opt="") override; virtual void SetErrorOption(Option_t *option=""); // *MENU* void Sumw2(Bool_t flag = kTRUE) override; diff --git a/hist/hist/src/TH1.cxx b/hist/hist/src/TH1.cxx index e0aee3b92f692..84458d90440f2 100644 --- a/hist/hist/src/TH1.cxx +++ b/hist/hist/src/TH1.cxx @@ -6695,9 +6695,9 @@ UInt_t TH1::GetAxisLabelStatus() const /// or equal to its upper limit, the function SetBuffer is automatically /// called with the default buffer size. -void TH1::SetDefaultBufferSize(Int_t buffersize) +void TH1::SetDefaultBufferSize(Int_t bufsize) { - fgBufferSize = buffersize > 0 ? buffersize : 0; + fgBufferSize = bufsize > 0 ? bufsize : 0; } //////////////////////////////////////////////////////////////////////////////// @@ -8453,19 +8453,19 @@ Double_t TH1::GetContourLevelPad(Int_t level) const //////////////////////////////////////////////////////////////////////////////// /// Set the maximum number of entries to be kept in the buffer. -void TH1::SetBuffer(Int_t buffersize, Option_t * /*option*/) +void TH1::SetBuffer(Int_t bufsize, Option_t * /*option*/) { if (fBuffer) { BufferEmpty(); delete [] fBuffer; fBuffer = nullptr; } - if (buffersize <= 0) { + if (bufsize <= 0) { fBufferSize = 0; return; } - if (buffersize < 100) buffersize = 100; - fBufferSize = 1 + buffersize*(fDimension+1); + if (bufsize < 100) bufsize = 100; + fBufferSize = 1 + bufsize*(fDimension+1); fBuffer = new Double_t[fBufferSize]; memset(fBuffer, 0, sizeof(Double_t)*fBufferSize); } diff --git a/hist/hist/src/TProfile.cxx b/hist/hist/src/TProfile.cxx index 8cd32048ba9da..80d5247596a4a 100644 --- a/hist/hist/src/TProfile.cxx +++ b/hist/hist/src/TProfile.cxx @@ -1742,19 +1742,19 @@ void TProfile::SetBinsLength(Int_t n) //////////////////////////////////////////////////////////////////////////////// /// Set the buffer size in units of 8 bytes (double). -void TProfile::SetBuffer(Int_t buffersize, Option_t *) +void TProfile::SetBuffer(Int_t bufsize, Option_t *) { if (fBuffer) { BufferEmpty(); delete [] fBuffer; fBuffer = nullptr; } - if (buffersize <= 0) { + if (bufsize <= 0) { fBufferSize = 0; return; } - if (buffersize < 100) buffersize = 100; - fBufferSize = 1 + 3*buffersize; + if (bufsize < 100) bufsize = 100; + fBufferSize = 1 + 3*bufsize; fBuffer = new Double_t[fBufferSize]; memset(fBuffer,0,sizeof(Double_t)*fBufferSize); } diff --git a/hist/hist/src/TProfile2D.cxx b/hist/hist/src/TProfile2D.cxx index 63f8136c1c1d5..aad49759731bf 100644 --- a/hist/hist/src/TProfile2D.cxx +++ b/hist/hist/src/TProfile2D.cxx @@ -1995,19 +1995,19 @@ void TProfile2D::SetBinsLength(Int_t n) //////////////////////////////////////////////////////////////////////////////// /// Set the buffer size in units of 8 bytes (double). -void TProfile2D::SetBuffer(Int_t buffersize, Option_t *) +void TProfile2D::SetBuffer(Int_t bufsize, Option_t *) { if (fBuffer) { BufferEmpty(); delete [] fBuffer; fBuffer = nullptr; } - if (buffersize <= 0) { + if (bufsize <= 0) { fBufferSize = 0; return; } - if (buffersize < 100) buffersize = 100; - fBufferSize = 1 + 4*buffersize; + if (bufsize < 100) bufsize = 100; + fBufferSize = 1 + 4*bufsize; fBuffer = new Double_t[fBufferSize]; memset(fBuffer,0,sizeof(Double_t)*fBufferSize); } diff --git a/hist/hist/src/TProfile3D.cxx b/hist/hist/src/TProfile3D.cxx index 8f7745d28cdd8..8703c8d30577e 100644 --- a/hist/hist/src/TProfile3D.cxx +++ b/hist/hist/src/TProfile3D.cxx @@ -1364,19 +1364,19 @@ void TProfile3D::SetBinsLength(Int_t n) //////////////////////////////////////////////////////////////////////////////// /// Set the buffer size in units of 8 bytes (double). -void TProfile3D::SetBuffer(Int_t buffersize, Option_t *) +void TProfile3D::SetBuffer(Int_t bufsize, Option_t *) { if (fBuffer) { BufferEmpty(); delete [] fBuffer; fBuffer = nullptr; } - if (buffersize <= 0) { + if (bufsize <= 0) { fBufferSize = 0; return; } - if (buffersize < 100) buffersize = 100; - fBufferSize = 1 + 5*buffersize; + if (bufsize < 100) bufsize = 100; + fBufferSize = 1 + 5*bufsize; fBuffer = new Double_t[fBufferSize]; memset(fBuffer,0,sizeof(Double_t)*fBufferSize); } diff --git a/hist/histpainter/src/TPainter3dAlgorithms.cxx b/hist/histpainter/src/TPainter3dAlgorithms.cxx index c3ceed5fcdb76..94da4349b38d9 100644 --- a/hist/histpainter/src/TPainter3dAlgorithms.cxx +++ b/hist/histpainter/src/TPainter3dAlgorithms.cxx @@ -2000,8 +2000,8 @@ void TPainter3dAlgorithms::InitRaster(Double_t xmin, Double_t ymin, Double_t xma fDYrast = ymax - ymin; // Create buffer for raster - Int_t buffersize = nx*ny/30 + 1; - fRaster.resize(buffersize); + Int_t bufsize = nx*ny/30 + 1; + fRaster.resize(bufsize); // S E T M A S K S k = 0; diff --git a/io/io/inc/TBufferFile.h b/io/io/inc/TBufferFile.h index 57ca611463a8d..5aaf5f1916f83 100644 --- a/io/io/inc/TBufferFile.h +++ b/io/io/inc/TBufferFile.h @@ -69,8 +69,8 @@ class TBufferFile : public TBufferIO { enum { kStreamedMemberWise = BIT(14) }; //added to version number to know if a collection has been stored member-wise TBufferFile(TBuffer::EMode mode); - TBufferFile(TBuffer::EMode mode, Int_t bufsiz); - TBufferFile(TBuffer::EMode mode, Int_t bufsiz, void *buf, Bool_t adopt = kTRUE, ReAllocCharFun_t reallocfunc = nullptr); + TBufferFile(TBuffer::EMode mode, Int_t bufsize); + TBufferFile(TBuffer::EMode mode, Int_t bufsize, void *buf, Bool_t adopt = kTRUE, ReAllocCharFun_t reallocfunc = nullptr); ~TBufferFile() override; Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss) override; diff --git a/io/io/inc/TBufferIO.h b/io/io/inc/TBufferIO.h index 09265c90377b4..1500beed2616e 100644 --- a/io/io/inc/TBufferIO.h +++ b/io/io/inc/TBufferIO.h @@ -44,8 +44,8 @@ class TBufferIO : public TBuffer { TBufferIO() {} // NOLINT: not allowed to use = default because of TObject::kIsOnHeap detection, see ROOT-10300 TBufferIO(TBuffer::EMode mode); - TBufferIO(TBuffer::EMode mode, Int_t bufsiz); - TBufferIO(TBuffer::EMode mode, Int_t bufsiz, void *buf, Bool_t adopt = kTRUE, + TBufferIO(TBuffer::EMode mode, Int_t bufsize); + TBufferIO(TBuffer::EMode mode, Int_t bufsize, void *buf, Bool_t adopt = kTRUE, ReAllocCharFun_t reallocfunc = nullptr); //////////////////////////////////////////////////////////////////////////////// diff --git a/io/io/inc/TFile.h b/io/io/inc/TFile.h index dbf1c1ec2596f..9ffeb05e65a61 100644 --- a/io/io/inc/TFile.h +++ b/io/io/inc/TFile.h @@ -290,7 +290,7 @@ class TFile : public TDirectoryFile { void Close(Option_t *option="") override; // *MENU* void Copy(TObject &) const override { MayNotUse("Copy(TObject &)"); } - virtual Bool_t Cp(const char *dst, Bool_t progressbar = kTRUE,UInt_t buffersize = 1000000); + virtual Bool_t Cp(const char *dst, Bool_t progressbar = kTRUE,UInt_t bufsize = 1000000); virtual TKey* CreateKey(TDirectory* mother, const TObject* obj, const char* name, Int_t bufsize); virtual TKey* CreateKey(TDirectory* mother, const void* obj, const TClass* cl, const char* name, Int_t bufsize); @@ -379,8 +379,8 @@ class TFile : public TDirectoryFile { Int_t Sizeof() const override; void SumBuffer(Int_t bufsize); virtual Bool_t WriteBuffer(const char *buf, Int_t len); - Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsiz=0) override; - Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsiz=0) const override; + Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsize=0) override; + Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsize=0) const override; virtual void WriteFree(); virtual void WriteHeader(); virtual UShort_t WriteProcessID(TProcessID *pid); diff --git a/io/io/inc/TFileCacheRead.h b/io/io/inc/TFileCacheRead.h index 7bd232693e232..0f05c7e8bb199 100644 --- a/io/io/inc/TFileCacheRead.h +++ b/io/io/inc/TFileCacheRead.h @@ -78,7 +78,7 @@ class TFileCacheRead : public TObject { public: TFileCacheRead(); - TFileCacheRead(TFile *file, Int_t buffersize, TObject *tree = nullptr); + TFileCacheRead(TFile *file, Int_t bufsize, TObject *tree = nullptr); ~TFileCacheRead() override; virtual Int_t AddBranch(TBranch * /*b*/, Bool_t /*subbranches*/ = kFALSE) { return 0; } virtual Int_t AddBranch(const char * /*branch*/, Bool_t /*subbranches*/ = kFALSE) { return 0; } diff --git a/io/io/inc/TFileCacheWrite.h b/io/io/inc/TFileCacheWrite.h index 10cdeba203f80..83366eabcfc68 100644 --- a/io/io/inc/TFileCacheWrite.h +++ b/io/io/inc/TFileCacheWrite.h @@ -32,7 +32,7 @@ class TFileCacheWrite : public TObject { public: TFileCacheWrite(); - TFileCacheWrite(TFile *file, Int_t buffersize); + TFileCacheWrite(TFile *file, Int_t bufsize); ~TFileCacheWrite() override; virtual Bool_t Flush(); virtual Int_t GetBytesInCache() const { return fNtot; } diff --git a/io/io/src/TBufferFile.cxx b/io/io/src/TBufferFile.cxx index 84081aa021a83..931787c172025 100644 --- a/io/io/src/TBufferFile.cxx +++ b/io/io/src/TBufferFile.cxx @@ -85,8 +85,8 @@ TBufferFile::TBufferFile(TBuffer::EMode mode) /// Create an I/O buffer object. Mode should be either TBuffer::kRead or /// TBuffer::kWrite. -TBufferFile::TBufferFile(TBuffer::EMode mode, Int_t bufsiz) - :TBufferIO(mode,bufsiz), +TBufferFile::TBufferFile(TBuffer::EMode mode, Int_t bufsize) + :TBufferIO(mode,bufsize), fInfo(nullptr), fInfoStack() { } @@ -102,8 +102,8 @@ TBufferFile::TBufferFile(TBuffer::EMode mode, Int_t bufsiz) /// is provided, a Fatal error will be issued if the Buffer attempts to /// expand. -TBufferFile::TBufferFile(TBuffer::EMode mode, Int_t bufsiz, void *buf, Bool_t adopt, ReAllocCharFun_t reallocfunc) : - TBufferIO(mode,bufsiz,buf,adopt,reallocfunc), +TBufferFile::TBufferFile(TBuffer::EMode mode, Int_t bufsize, void *buf, Bool_t adopt, ReAllocCharFun_t reallocfunc) : + TBufferIO(mode,bufsize,buf,adopt,reallocfunc), fInfo(nullptr), fInfoStack() { } diff --git a/io/io/src/TBufferIO.cxx b/io/io/src/TBufferIO.cxx index 1e1fa5fe65e59..fe2efabeaa052 100644 --- a/io/io/src/TBufferIO.cxx +++ b/io/io/src/TBufferIO.cxx @@ -48,7 +48,7 @@ TBufferIO::TBufferIO(TBuffer::EMode mode) : TBuffer(mode) //////////////////////////////////////////////////////////////////////////////// /// constructor -TBufferIO::TBufferIO(TBuffer::EMode mode, Int_t bufsiz) : TBuffer(mode, bufsiz) +TBufferIO::TBufferIO(TBuffer::EMode mode, Int_t bufsize) : TBuffer(mode, bufsize) { fMapSize = fgMapSize; } @@ -56,8 +56,8 @@ TBufferIO::TBufferIO(TBuffer::EMode mode, Int_t bufsiz) : TBuffer(mode, bufsiz) //////////////////////////////////////////////////////////////////////////////// /// constructor -TBufferIO::TBufferIO(TBuffer::EMode mode, Int_t bufsiz, void *buf, Bool_t adopt, ReAllocCharFun_t reallocfunc) - : TBuffer(mode, bufsiz, buf, adopt, reallocfunc) +TBufferIO::TBufferIO(TBuffer::EMode mode, Int_t bufsize, void *buf, Bool_t adopt, ReAllocCharFun_t reallocfunc) + : TBuffer(mode, bufsize, buf, adopt, reallocfunc) { fMapSize = fgMapSize; } diff --git a/io/io/src/TFile.cxx b/io/io/src/TFile.cxx index 70aa2f1ca1ff9..49cdd4caf302f 100644 --- a/io/io/src/TFile.cxx +++ b/io/io/src/TFile.cxx @@ -2475,7 +2475,7 @@ void TFile::SumBuffer(Int_t bufsize) /// The linked list of FREE segments is written. /// The file header is written (bytes 1->fBEGIN). -Int_t TFile::Write(const char *, Int_t opt, Int_t bufsiz) +Int_t TFile::Write(const char *, Int_t opt, Int_t bufsize) { if (!IsWritable()) { if (!TestBit(kWriteError)) { @@ -2493,7 +2493,7 @@ Int_t TFile::Write(const char *, Int_t opt, Int_t bufsiz) } fMustFlush = kFALSE; - Int_t nbytes = TDirectoryFile::Write(0, opt, bufsiz); // Write directory tree + Int_t nbytes = TDirectoryFile::Write(0, opt, bufsize); // Write directory tree WriteStreamerInfo(); WriteFree(); // Write free segments linked list WriteHeader(); // Now write file header @@ -5049,7 +5049,7 @@ void TFile::CpProgress(Long64_t bytesread, Long64_t size, TStopwatch &watch) /// Allows to copy this file to the dst URL. Returns kTRUE in case of success, /// kFALSE otherwise. -Bool_t TFile::Cp(const char *dst, Bool_t progressbar, UInt_t buffersize) +Bool_t TFile::Cp(const char *dst, Bool_t progressbar, UInt_t bufsize) { Bool_t rmdestiferror = kFALSE; TStopwatch watch; @@ -5104,7 +5104,7 @@ Bool_t TFile::Cp(const char *dst, Bool_t progressbar, UInt_t buffersize) sfile->Seek(0); dfile->Seek(0); - copybuffer = new char[buffersize]; + copybuffer = new char[bufsize]; if (!copybuffer) { ::Error("TFile::Cp", "cannot allocate the copy buffer"); goto copyout; @@ -5126,8 +5126,8 @@ Bool_t TFile::Cp(const char *dst, Bool_t progressbar, UInt_t buffersize) Long64_t b1 = sfile->GetBytesRead() - b00; Long64_t readsize; - if (filesize - b1 > (Long64_t)buffersize) { - readsize = buffersize; + if (filesize - b1 > (Long64_t)bufsize) { + readsize = bufsize; } else { readsize = filesize - b1; } @@ -5152,7 +5152,7 @@ Bool_t TFile::Cp(const char *dst, Bool_t progressbar, UInt_t buffersize) goto copyout; } totalread += read; - } while (read == (Long64_t)buffersize); + } while (read == (Long64_t)bufsize); if (progressbar) { CpProgress(totalread, filesize,watch); @@ -5181,7 +5181,7 @@ Bool_t TFile::Cp(const char *dst, Bool_t progressbar, UInt_t buffersize) /// kFALSE otherwise. Bool_t TFile::Cp(const char *src, const char *dst, Bool_t progressbar, - UInt_t buffersize) + UInt_t bufsize) { TUrl sURL(src, kTRUE); @@ -5193,7 +5193,7 @@ Bool_t TFile::Cp(const char *src, const char *dst, Bool_t progressbar, if (!(sfile = TFile::Open(sURL.GetUrl(), "READ"))) { ::Error("TFile::Cp", "cannot open source file %s", src); } else { - success = sfile->Cp(dst, progressbar, buffersize); + success = sfile->Cp(dst, progressbar, bufsize); } if (sfile) { diff --git a/io/io/src/TFileCacheRead.cxx b/io/io/src/TFileCacheRead.cxx index de5eddbe49640..670f1712c4611 100644 --- a/io/io/src/TFileCacheRead.cxx +++ b/io/io/src/TFileCacheRead.cxx @@ -90,11 +90,11 @@ TFileCacheRead::TFileCacheRead() : TObject() //////////////////////////////////////////////////////////////////////////////// /// Creates a TFileCacheRead data structure. -TFileCacheRead::TFileCacheRead(TFile *file, Int_t buffersize, TObject *tree) +TFileCacheRead::TFileCacheRead(TFile *file, Int_t bufsize, TObject *tree) : TObject() { - if (buffersize <=10000) fBufferSize = 100000; - else fBufferSize = buffersize; + if (bufsize <=10000) fBufferSize = 100000; + else fBufferSize = bufsize; fBufferSizeMin = fBufferSize; fBufferLen = 0; @@ -708,25 +708,25 @@ void TFileCacheRead::WaitFinishPrefetch() /// - 1 if some or all blocks have been removed from the prefetch list /// - -1 on error -Int_t TFileCacheRead::SetBufferSize(Long64_t buffersize) +Int_t TFileCacheRead::SetBufferSize(Long64_t bufsize) { - if (buffersize <= 0) return -1; - if (buffersize <=10000) buffersize = 100000; - if (buffersize > std::numeric_limits::max()) buffersize = std::numeric_limits::max(); + if (bufsize <= 0) return -1; + if (bufsize <=10000) bufsize = 100000; + if (bufsize > std::numeric_limits::max()) bufsize = std::numeric_limits::max(); - if (buffersize == fBufferSize) { - fBufferSizeMin = buffersize; + if (bufsize == fBufferSize) { + fBufferSizeMin = bufsize; return 0; } Bool_t inval = kFALSE; // the cached data is too large to fit in the new buffer size mark data unavailable - if (fNtot > buffersize) { + if (fNtot > bufsize) { Prefetch(0, 0); inval = kTRUE; } - if (fBNtot > buffersize) { + if (fBNtot > bufsize) { SecondPrefetch(0, 0); inval = kTRUE; } @@ -741,7 +741,7 @@ Int_t TFileCacheRead::SetBufferSize(Long64_t buffersize) } delete [] fBuffer; fBuffer = 0; - np = new char[buffersize]; + np = new char[bufsize]; if (pres) { memcpy(np, pres, fNtot); } @@ -750,8 +750,8 @@ Int_t TFileCacheRead::SetBufferSize(Long64_t buffersize) delete [] fBuffer; fBuffer = np; - fBufferSizeMin = buffersize; - fBufferSize = buffersize; + fBufferSizeMin = bufsize; + fBufferSize = bufsize; if (inval) { return 1; diff --git a/io/io/src/TFileCacheWrite.cxx b/io/io/src/TFileCacheWrite.cxx index 5fb668bd9d514..e69943f9aaafd 100644 --- a/io/io/src/TFileCacheWrite.cxx +++ b/io/io/src/TFileCacheWrite.cxx @@ -47,21 +47,21 @@ TFileCacheWrite::TFileCacheWrite() : TObject() //////////////////////////////////////////////////////////////////////////////// /// Creates a TFileCacheWrite data structure. /// The write cache will be connected to file. -/// The size of the cache will be buffersize, -/// if buffersize < 10000 a default size of 512 Kbytes is used +/// The size of the cache will be bufsize, +/// if bufsize < 10000 a default size of 512 Kbytes is used -TFileCacheWrite::TFileCacheWrite(TFile *file, Int_t buffersize) +TFileCacheWrite::TFileCacheWrite(TFile *file, Int_t bufsize) : TObject() { - if (buffersize < 10000) buffersize = 512000; - fBufferSize = buffersize; + if (bufsize < 10000) bufsize = 512000; + fBufferSize = bufsize; fSeekStart = 0; fNtot = 0; fFile = file; fRecursive = kFALSE; fBuffer = new char[fBufferSize]; if (file) file->SetCacheWrite(this); - if (gDebug > 0) Info("TFileCacheWrite","Creating a write cache with buffersize=%d bytes",buffersize); + if (gDebug > 0) Info("TFileCacheWrite","Creating a write cache with buffersize=%d bytes",bufsize); } //////////////////////////////////////////////////////////////////////////////// diff --git a/io/sql/inc/TSQLFile.h b/io/sql/inc/TSQLFile.h index 0ece3679ae096..7c26c41bb9c3f 100644 --- a/io/sql/inc/TSQLFile.h +++ b/io/sql/inc/TSQLFile.h @@ -205,7 +205,7 @@ class TSQLFile final : public TFile { void StopLogFile(); // *MENU* void Close(Option_t *option = "") final; // *MENU* - TKey *CreateKey(TDirectory *mother, const TObject *obj, const char *name, Int_t bufsize) final; + TKey *CreateKey(TDirectory *mother, const TObject *obj, const char *name, Int_t bufsize) final; TKey *CreateKey(TDirectory *mother, const void *obj, const TClass *cl, const char *name, Int_t bufsize) final; void DrawMap(const char * = "*", Option_t * = "") final {} void FillBuffer(char *&) final {} diff --git a/net/net/inc/TMessage.h b/net/net/inc/TMessage.h index 5d3e8833083a0..90f4f377d1577 100644 --- a/net/net/inc/TMessage.h +++ b/net/net/inc/TMessage.h @@ -66,7 +66,7 @@ friend class TXSocket; void SetLength() const; // only called by T(P)Socket::Send() public: - TMessage(UInt_t what = kMESS_ANY, Int_t bufsiz = TBuffer::kInitialSize); + TMessage(UInt_t what = kMESS_ANY, Int_t bufsize = TBuffer::kInitialSize); virtual ~TMessage(); void ForceWriteInfo(TVirtualStreamerInfo *info, Bool_t force) override; diff --git a/net/net/inc/TParallelMergingFile.h b/net/net/inc/TParallelMergingFile.h index 18715c65e6f8e..8f15d7ccee07c 100644 --- a/net/net/inc/TParallelMergingFile.h +++ b/net/net/inc/TParallelMergingFile.h @@ -51,8 +51,8 @@ class TParallelMergingFile : public TMemFile void Close(Option_t *option="") override; Bool_t UploadAndReset(); - Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsiz=0) override; - Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsiz=0) const override; + Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsize=0) override; + Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsize=0) const override; void WriteStreamerInfo() override; Int_t GetServerIdx() const { return fServerIdx; } diff --git a/net/net/src/TMessage.cxx b/net/net/src/TMessage.cxx index b555ffc993aab..4fd724a8d58b5 100644 --- a/net/net/src/TMessage.cxx +++ b/net/net/src/TMessage.cxx @@ -43,8 +43,8 @@ ClassImp(TMessage); /// the message will be compressed in TSocket using the zip algorithm /// (only if message is > 256 bytes). -TMessage::TMessage(UInt_t what, Int_t bufsiz) : - TBufferFile(TBuffer::kWrite, bufsiz + 2*sizeof(UInt_t)), +TMessage::TMessage(UInt_t what, Int_t bufsize) : + TBufferFile(TBuffer::kWrite, bufsize + 2*sizeof(UInt_t)), fCompress(ROOT::RCompressionSetting::EAlgorithm::kUseGlobal) { // space at the beginning of the message reserved for the message length diff --git a/net/net/src/TParallelMergingFile.cxx b/net/net/src/TParallelMergingFile.cxx index ef94964d24ad6..894a093578611 100644 --- a/net/net/src/TParallelMergingFile.cxx +++ b/net/net/src/TParallelMergingFile.cxx @@ -175,9 +175,9 @@ Bool_t TParallelMergingFile::UploadAndReset() /// The linked list of FREE segments is written. /// The file header is written (bytes 1->fBEGIN). -Int_t TParallelMergingFile::Write(const char *, Int_t opt, Int_t bufsiz) +Int_t TParallelMergingFile::Write(const char *, Int_t opt, Int_t bufsize) { - Int_t nbytes = TMemFile::Write(0,opt,bufsiz); + Int_t nbytes = TMemFile::Write(0,opt,bufsize); if (nbytes) { UploadAndReset(); } diff --git a/tree/ntuple/src/RFieldMeta.cxx b/tree/ntuple/src/RFieldMeta.cxx index 1bdcef9d1ebd0..6e2b5aa17c87b 100644 --- a/tree/ntuple/src/RFieldMeta.cxx +++ b/tree/ntuple/src/RFieldMeta.cxx @@ -832,8 +832,8 @@ class TBufferRecStreamer : public TBufferFile { RCallbackStreamerInfo fCallbackStreamerInfo; public: - TBufferRecStreamer(TBuffer::EMode mode, Int_t bufsiz, RCallbackStreamerInfo callbackStreamerInfo) - : TBufferFile(mode, bufsiz), fCallbackStreamerInfo(callbackStreamerInfo) + TBufferRecStreamer(TBuffer::EMode mode, Int_t bufsize, RCallbackStreamerInfo callbackStreamerInfo) + : TBufferFile(mode, bufsize), fCallbackStreamerInfo(callbackStreamerInfo) { } void TagStreamerInfo(TVirtualStreamerInfo *info) final { fCallbackStreamerInfo(info); } diff --git a/tree/tree/inc/TBranch.h b/tree/tree/inc/TBranch.h index 48c7fd81035c9..a74cd85c01d15 100644 --- a/tree/tree/inc/TBranch.h +++ b/tree/tree/inc/TBranch.h @@ -270,7 +270,7 @@ class TBranch : public TNamed, public TAttFill { virtual void SetAddress(void *add); virtual void SetObject(void *objadd); virtual void SetAutoDelete(bool autodel=true); - virtual void SetBasketSize(Int_t buffsize); + virtual void SetBasketSize(Int_t bufsize); virtual void SetBufferAddress(TBuffer *entryBuffer); void SetCompressionAlgorithm(Int_t algorithm = ROOT::RCompressionSetting::EAlgorithm::kUseGlobal); void SetCompressionLevel(Int_t level = ROOT::RCompressionSetting::ELevel::kUseMin); diff --git a/tree/tree/inc/TBranchClones.h b/tree/tree/inc/TBranchClones.h index b11b340e26e14..6154609a91906 100644 --- a/tree/tree/inc/TBranchClones.h +++ b/tree/tree/inc/TBranchClones.h @@ -57,7 +57,7 @@ class TBranchClones : public TBranch { void Reset(Option_t *option="") override; void ResetAfterMerge(TFileMergeInfo *) override; void SetAddress(void *add) override; - void SetBasketSize(Int_t buffsize) override; + void SetBasketSize(Int_t bufsize) override; void SetTree(TTree *tree) override { fTree = tree; fBranchCount->SetTree(tree); } void UpdateFile() override; diff --git a/tree/tree/inc/TBranchElement.h b/tree/tree/inc/TBranchElement.h index c329178d2aeb6..1caa795fdf0d2 100644 --- a/tree/tree/inc/TBranchElement.h +++ b/tree/tree/inc/TBranchElement.h @@ -222,7 +222,7 @@ class TBranchElement : public TBranch { void SetAddress(void* addobj) override; bool SetMakeClass(bool decomposeObj = true) override; void SetObject(void *objadd) override; - void SetBasketSize(Int_t buffsize) override; + void SetBasketSize(Int_t bufsize) override; virtual void SetBranchFolder() { SetBit(kBranchFolder); } virtual void SetClassName(const char* name) { fClassName = name; } void SetOffset(Int_t offset) override; diff --git a/tree/tree/inc/TBranchObject.h b/tree/tree/inc/TBranchObject.h index 2162b50e24bfa..75dbbf96e5cf2 100644 --- a/tree/tree/inc/TBranchObject.h +++ b/tree/tree/inc/TBranchObject.h @@ -61,7 +61,7 @@ class TBranchObject : public TBranch { void ResetAfterMerge(TFileMergeInfo *) override; void SetAddress(void *addobj) override; void SetAutoDelete(bool autodel=true) override; - void SetBasketSize(Int_t buffsize) override; + void SetBasketSize(Int_t bufsize) override; void SetupAddresses() override; void UpdateAddress() override; diff --git a/tree/tree/inc/TBranchSTL.h b/tree/tree/inc/TBranchSTL.h index 3fc35b0f0c3c5..9afff67341619 100644 --- a/tree/tree/inc/TBranchSTL.h +++ b/tree/tree/inc/TBranchSTL.h @@ -24,10 +24,10 @@ class TBranchSTL: public TBranch { TBranchSTL(); TBranchSTL( TTree* tree, const char* name, TVirtualCollectionProxy* collProxy, - Int_t buffsize, Int_t splitlevel ); + Int_t bufsize, Int_t splitlevel ); TBranchSTL( TBranch* parent, const char* name, TVirtualCollectionProxy* collProxy, - Int_t buffsize, Int_t splitlevel, + Int_t bufsize, Int_t splitlevel, TStreamerInfo* info, Int_t id ); ~TBranchSTL() override; void Browse( TBrowser *b ) override; diff --git a/tree/tree/inc/TTreeCache.h b/tree/tree/inc/TTreeCache.h index ee2a3d96a52df..9b8621c3d7be7 100644 --- a/tree/tree/inc/TTreeCache.h +++ b/tree/tree/inc/TTreeCache.h @@ -127,7 +127,7 @@ class TTreeCache : public TFileCacheRead { public: TTreeCache(); - TTreeCache(TTree *tree, Int_t buffersize=0); + TTreeCache(TTree *tree, Int_t bufsize=0); ~TTreeCache() override; Int_t AddBranch(TBranch *b, bool subgbranches = false) override; Int_t AddBranch(const char *branch, bool subbranches = false) override; diff --git a/tree/tree/src/TBranch.cxx b/tree/tree/src/TBranch.cxx index 556d7c1df20e5..1fd91674fe754 100644 --- a/tree/tree/src/TBranch.cxx +++ b/tree/tree/src/TBranch.cxx @@ -2739,11 +2739,11 @@ void TBranch::SetAutoDelete(bool autodel) /// Set the basket size /// The function makes sure that the basket size is greater than fEntryOffsetlen -void TBranch::SetBasketSize(Int_t buffsize) +void TBranch::SetBasketSize(Int_t bufsize) { Int_t minsize = 100 + fName.Length(); - if (buffsize < minsize+fEntryOffsetLen) buffsize = minsize+fEntryOffsetLen; - fBasketSize = buffsize; + if (bufsize < minsize+fEntryOffsetLen) bufsize = minsize+fEntryOffsetLen; + fBasketSize = bufsize; TBasket *basket = (TBasket*)fBaskets[fWriteBasket]; if (basket) { basket->AdjustSize(fBasketSize); diff --git a/tree/tree/src/TBranchClones.cxx b/tree/tree/src/TBranchClones.cxx index 7a5b11b996fef..bea3cf646b237 100644 --- a/tree/tree/src/TBranchClones.cxx +++ b/tree/tree/src/TBranchClones.cxx @@ -370,9 +370,9 @@ void TBranchClones::SetAddress(void* addr) //////////////////////////////////////////////////////////////////////////////// /// Reset basket size for all sub-branches. -void TBranchClones::SetBasketSize(Int_t buffsize) +void TBranchClones::SetBasketSize(Int_t bufsize) { - TBranch::SetBasketSize(buffsize); + TBranch::SetBasketSize(bufsize); Int_t nbranches = fBranches.GetEntriesFast(); for (Int_t i = 0; i < nbranches; i++) { diff --git a/tree/tree/src/TBranchElement.cxx b/tree/tree/src/TBranchElement.cxx index 0548be76060df..d34de75418c2e 100644 --- a/tree/tree/src/TBranchElement.cxx +++ b/tree/tree/src/TBranchElement.cxx @@ -78,6 +78,40 @@ namespace { if (fOnfileObject) fBuffer.PopDataCache(); } }; + //////////////////////////////////////////////////////////////////////////////// + /// Check if a collection proxy represents an associative collection (e.g., std::map, std::set) + /// rather than a sequential collection (e.g., std::vector, std::list). + /// Both the version based on the fSTLtype integer and the one based on the TVirtualCollectionProxy + /// will return the same result about the 'currently' in memory collection attached to the branch. + /// The main difference is that the fSTLtype can be used without checking whether + /// fCollProxy is set or not but might (or might not) be a tad bit slower. + bool IsAssociativeContainer(Int_t stltype) + { + switch (stltype) { + case ROOT::kSTLset: + case ROOT::kSTLmultiset: + case ROOT::kSTLunorderedset: + case ROOT::kSTLunorderedmultiset: + case ROOT::kSTLmap: + case ROOT::kSTLmultimap: + case ROOT::kSTLunorderedmap: + case ROOT::kSTLunorderedmultimap: + return true; + default: + return false; + } + } + bool IsAssociativeContainer(const TVirtualCollectionProxy &proxy) + { + return proxy.GetProperties() & TVirtualCollectionProxy::kIsAssociative; + } + + void RecursiveResetReadEntry(TBranch *br) + { + br->ResetReadEntry(); + for (auto sub : *br->GetListOfBranches()) + RecursiveResetReadEntry(static_cast(sub)); + } } //////////////////////////////////////////////////////////////////////////////// @@ -86,7 +120,7 @@ namespace { void TBranchElement::SwitchContainer(TObjArray* branches) { const Int_t nbranches = branches->GetEntriesFast(); for (Int_t i = 0; i < nbranches; ++i) { - TBranchElement* br = (TBranchElement*) branches->At(i); + TBranchElement* br = static_cast(branches->At(i)); switch (br->GetType()) { case 31: br->SetType(41); break; case 41: { @@ -392,7 +426,7 @@ void TBranchElement::Init(TTree *tree, TBranch *parent,const char* bname, TStrea } if (element->IsA() == TStreamerBasicPointer::Class()) { // -- Fixup title with counter if we are a varying length array data member. - TStreamerBasicPointer *bp = (TStreamerBasicPointer *)element; + TStreamerBasicPointer *bp = dynamic_cast(element); TString countname; countname = bname; Ssiz_t dot = countname.Last('.'); @@ -402,13 +436,13 @@ void TBranchElement::Init(TTree *tree, TBranch *parent,const char* bname, TStrea countname = ""; } countname += bp->GetCountName(); - brOfCounter = (TBranchElement *)fTree->GetBranch(countname); + brOfCounter = static_cast(fTree->GetBranch(countname)); countname.Form("%s[%s]",name.Data(),bp->GetCountName()); SetTitle(countname); } else if (element->IsA() == TStreamerLoop::Class()) { // -- Fixup title with counter if we are a varying length array data member. - TStreamerLoop *bp = (TStreamerLoop *)element; + TStreamerLoop *bp = static_cast(element); TString countname; countname = bname; Ssiz_t dot = countname.Last('.'); @@ -418,7 +452,7 @@ void TBranchElement::Init(TTree *tree, TBranch *parent,const char* bname, TStrea countname = ""; } countname += bp->GetCountName(); - brOfCounter = (TBranchElement *)fTree->GetBranch(countname); + brOfCounter = static_cast(fTree->GetBranch(countname)); countname.Form("%s[%s]",name.Data(),bp->GetCountName()); SetTitle(countname); @@ -507,10 +541,10 @@ void TBranchElement::Init(TTree *tree, TBranch *parent,const char* bname, TStrea bool ispointer = element->IsaPointer(); TClonesArray *clones; if (ispointer) { - char **ppointer = (char**)(pointer); - clones = (TClonesArray*)(*ppointer); + char **ppointer = reinterpret_cast(pointer); + clones = reinterpret_cast(*ppointer); } else { - clones = (TClonesArray*)pointer; + clones = reinterpret_cast(pointer); } // basket->DeleteEntryOffset(); //entryoffset not required for the clonesarray counter fEntryOffsetLen = 0; @@ -664,7 +698,7 @@ TBranchElement::TBranchElement(TTree *tree, const char* bname, TClonesArray* clo : TBranch() , fClassName("TClonesArray") , fParentName() -, fInfo((TStreamerInfo*)TClonesArray::Class()->GetStreamerInfo()) +, fInfo(static_cast(TClonesArray::Class()->GetStreamerInfo())) , fInit(true) , fInInitInfo(false) , fInitOffsets(false) @@ -691,7 +725,7 @@ TBranchElement::TBranchElement(TBranch *parent, const char* bname, TClonesArray* : TBranch() , fClassName("TClonesArray") , fParentName() -, fInfo((TStreamerInfo*)TClonesArray::Class()->GetStreamerInfo()) +, fInfo(static_cast(TClonesArray::Class()->GetStreamerInfo())) , fInit(true) , fInInitInfo(false) , fInitOffsets(false) @@ -1037,7 +1071,7 @@ void TBranchElement::Browse(TBrowser* b) TList persistentBranches; TBranch* branch=nullptr; TIter iB(&fBranches); - while((branch=(TBranch*)iB())) { + while((branch=static_cast(iB()))) { if (branch->IsFolder()) persistentBranches.Add(branch); else { // only show branches corresponding to persistent members @@ -1053,9 +1087,10 @@ void TBranchElement::Browse(TBrowser* b) // we can only find out asking the streamer given our ID TStreamerElement *element=nullptr; TClass* clsub=nullptr; - if (fID>=0 && GetInfoImp() - && GetInfoImp()->IsCompiled() - && ((element=GetInfoImp()->GetElement(fID))) + auto info = (fID >= 0) ? GetInfoImp() : nullptr; + if (info + && info->IsCompiled() + && ((element=info->GetElement(fID))) && ((clsub=element->GetClassPointer()))) cl=clsub; } @@ -1155,7 +1190,7 @@ void TBranchElement::BuildTitle(const char* name) indexname += "_"; for (Int_t i = 0; i < nbranches; ++i) { - TBranchElement* bre = (TBranchElement*) fBranches.At(i); + TBranchElement* bre = static_cast(fBranches.At(i)); if (!bre) continue; if (fType == 3) { @@ -1173,7 +1208,7 @@ void TBranchElement::BuildTitle(const char* name) } // The branch counter for a sub-branch of a container is the container master branch. bre->SetBranchCount(this); - TLeafElement* lf = (TLeafElement*) bre->GetListOfLeaves()->At(0); + TLeafElement* lf = static_cast(bre->GetListOfLeaves()->At(0)); // If branch name is of the form fTracks.fCovar[3][4], then // set the title to fCovar[fTracks_]. branchname = fin+1; @@ -1206,10 +1241,10 @@ void TBranchElement::BuildTitle(const char* name) if (bn<0) { continue; } - TStreamerBasicPointer *el = (TStreamerBasicPointer*)bre->GetInfoImp()->GetElements()->FindObject(name2.Data()+bn+1); + TStreamerBasicPointer *el = dynamic_cast(bre->GetInfoImp()->GetElements()->FindObject(name2.Data()+bn+1)); name2.Remove(bn+1); if (el) name2 += el->GetCountName(); - TBranchElement *bc2 = (TBranchElement*)fBranches.FindObject(name2); + TBranchElement *bc2 = static_cast(fBranches.FindObject(name2)); bre->SetBranchCount2(bc2); } bre->SetReadLeavesPtr(); @@ -1286,7 +1321,7 @@ Int_t TBranchElement::FillImpl(ROOT::Internal::TBranchIMTHelper *imtHelper) ++fEntries; } for (Int_t i = 0; i < nbranches; ++i) { - TBranchElement* branch = (TBranchElement*) fBranches[i]; + TBranchElement* branch = static_cast(fBranches[i]); if (!branch->TestBit(kDoNotProcess)) { nwrite = branch->FillImpl(imtHelper); if (nwrite < 0) { @@ -1339,7 +1374,7 @@ void TBranchElement::FillLeavesMakeClass(TBuffer& b) return; } b.ForceWriteInfo(si,false); - Int_t* nptr = (Int_t*) fAddress; + Int_t* nptr = reinterpret_cast(fAddress); b << *nptr; } else if (fType == 31) { // -- TClonesArray sub-branch. Write out the entries in the TClonesArray. @@ -1360,7 +1395,7 @@ void TBranchElement::FillLeavesMakeClass(TBuffer& b) // arrays of kBits, kLong64, kULong64, nor kBool. return; } - Int_t* nn = (Int_t*) fBranchCount->GetAddress(); + Int_t* nn = reinterpret_cast(fBranchCount->GetAddress()); if (!nn) { Error("FillLeaves", "The branch counter address was zero!"); return; @@ -1373,24 +1408,24 @@ void TBranchElement::FillLeavesMakeClass(TBuffer& b) } if (atype > 20) { atype -= 20; - TLeafElement* leaf = (TLeafElement*) fLeaves.UncheckedAt(0); + TLeafElement* leaf = static_cast(fLeaves.UncheckedAt(0)); n = n * leaf->GetLenStatic(); } switch (atype) { // Note: Type 0 is a base class and cannot happen here, see Unroll(). - case TVirtualStreamerInfo::kChar /* 1 */: { b.WriteFastArray((Char_t*) fAddress, n); break; } - case TVirtualStreamerInfo::kShort /* 2 */: { b.WriteFastArray((Short_t*) fAddress, n); break; } - case TVirtualStreamerInfo::kInt /* 3 */: { b.WriteFastArray((Int_t*) fAddress, n); break; } - case TVirtualStreamerInfo::kLong /* 4 */: { b.WriteFastArray((Long_t*) fAddress, n); break; } - case TVirtualStreamerInfo::kFloat /* 5 */: { b.WriteFastArray((Float_t*) fAddress, n); break; } - case TVirtualStreamerInfo::kCounter /* 6 */: { b.WriteFastArray((Int_t*) fAddress, n); break; } + case TVirtualStreamerInfo::kChar /* 1 */: { b.WriteFastArray(reinterpret_cast(fAddress), n); break; } + case TVirtualStreamerInfo::kShort /* 2 */: { b.WriteFastArray(reinterpret_cast(fAddress), n); break; } + case TVirtualStreamerInfo::kInt /* 3 */: { b.WriteFastArray(reinterpret_cast(fAddress), n); break; } + case TVirtualStreamerInfo::kLong /* 4 */: { b.WriteFastArray(reinterpret_cast(fAddress), n); break; } + case TVirtualStreamerInfo::kFloat /* 5 */: { b.WriteFastArray(reinterpret_cast(fAddress), n); break; } + case TVirtualStreamerInfo::kCounter /* 6 */: { b.WriteFastArray(reinterpret_cast(fAddress), n); break; } // FIXME: We do nothing with type 7 (TVirtualStreamerInfo::kCharStar, char*) here! - case TVirtualStreamerInfo::kDouble /* 8 */: { b.WriteFastArray((Double_t*) fAddress, n); break; } + case TVirtualStreamerInfo::kDouble /* 8 */: { b.WriteFastArray(reinterpret_cast(fAddress), n); break; } case TVirtualStreamerInfo::kDouble32 /* 9 */: { TVirtualStreamerInfo* si = GetInfoImp(); // coverity[returned_null] structurally si->fComp (used in GetElem) can not be null. TStreamerElement* se = si->GetElement(fID); - Double_t* xx = (Double_t*) fAddress; + Double_t* xx = reinterpret_cast(fAddress); for (Int_t ii = 0; ii < n; ++ii) { b.WriteDouble32(&(xx[ii]),se); } @@ -1399,23 +1434,23 @@ void TBranchElement::FillLeavesMakeClass(TBuffer& b) case TVirtualStreamerInfo::kFloat16 /* 19 */: { TVirtualStreamerInfo* si = GetInfoImp(); // coverity[dereference] structurally si can not be null. - TStreamerElement* se = (TStreamerElement*) si->GetElement(fID); - Float_t* xx = (Float_t*) fAddress; + TStreamerElement* se = static_cast(si->GetElement(fID)); + Float_t* xx = reinterpret_cast(fAddress); for (Int_t ii = 0; ii < n; ++ii) { b.WriteFloat16(&(xx[ii]),se); } break; } // Note: Type 10 is unused for now. - case TVirtualStreamerInfo::kUChar /* 11 */: { b.WriteFastArray((UChar_t*) fAddress, n); break; } - case TVirtualStreamerInfo::kUShort /* 12 */: { b.WriteFastArray((UShort_t*) fAddress, n); break; } - case TVirtualStreamerInfo::kUInt /* 13 */: { b.WriteFastArray((UInt_t*) fAddress, n); break; } - case TVirtualStreamerInfo::kULong /* 14 */: { b.WriteFastArray((ULong_t*) fAddress, n); break; } + case TVirtualStreamerInfo::kUChar /* 11 */: { b.WriteFastArray(reinterpret_cast(fAddress), n); break; } + case TVirtualStreamerInfo::kUShort /* 12 */: { b.WriteFastArray(reinterpret_cast(fAddress), n); break; } + case TVirtualStreamerInfo::kUInt /* 13 */: { b.WriteFastArray(reinterpret_cast(fAddress), n); break; } + case TVirtualStreamerInfo::kULong /* 14 */: { b.WriteFastArray(reinterpret_cast(fAddress), n); break; } // FIXME: This is wrong!!! TVirtualStreamerInfo::kBits is a variable length type. - case TVirtualStreamerInfo::kBits /* 15 */: { b.WriteFastArray((UInt_t*) fAddress, n); break; } - case TVirtualStreamerInfo::kLong64 /* 16 */: { b.WriteFastArray((Long64_t*) fAddress, n); break; } - case TVirtualStreamerInfo::kULong64 /* 17 */: { b.WriteFastArray((ULong64_t*) fAddress, n); break; } - case TVirtualStreamerInfo::kBool /* 18 */: { b.WriteFastArray((bool*) fAddress, n); break; } + case TVirtualStreamerInfo::kBits /* 15 */: { b.WriteFastArray(reinterpret_cast(fAddress), n); break; } + case TVirtualStreamerInfo::kLong64 /* 16 */: { b.WriteFastArray(reinterpret_cast(fAddress), n); break; } + case TVirtualStreamerInfo::kULong64 /* 17 */: { b.WriteFastArray(reinterpret_cast(fAddress), n); break; } + case TVirtualStreamerInfo::kBool /* 18 */: { b.WriteFastArray(reinterpret_cast(fAddress), n); break; } } } } @@ -1454,7 +1489,7 @@ void TBranchElement::FillLeavesCollection(TBuffer& b) //NOTE: this does not work for not vectors since the CreateIterators expects a TGenCollectionProxy::TStaging as its argument! //NOTE: and those not work in general yet, since the TStaging object is neither created nor passed. // We need to review how to avoid the need for a TStaging during the writing. - if (proxy->GetProperties() & TVirtualCollectionProxy::kIsAssociative) { + if (IsAssociativeContainer(*proxy)) { fWriteIterators->CreateIterators(fObject, proxy); } else { fIterators->CreateIterators(fObject, proxy); @@ -1482,7 +1517,7 @@ void TBranchElement::FillLeavesCollectionSplitVectorPtrMember(TBuffer& b) // FIXME: This wont work if a pointer to vector is split! TVirtualCollectionProxy::TPushPop helper(GetCollectionProxy(), fObject); // Note: We cannot pop the proxy here because we need it for the i/o. - TStreamerInfo* si = (TStreamerInfo*)GetInfoImp(); + TStreamerInfo* si = static_cast(GetInfoImp()); if (!si) { Error("FillLeaves", "Cannot get streamer info for branch '%s'", GetName()); return; @@ -1513,7 +1548,7 @@ void TBranchElement::FillLeavesCollectionSplitPtrMember(TBuffer& b) TVirtualCollectionProxy::TPushPop helper(GetCollectionProxy(), fObject); // Note: We cannot pop the proxy here because we need it for the i/o. - TStreamerInfo* si = (TStreamerInfo*)GetInfoImp(); + TStreamerInfo* si = static_cast(GetInfoImp()); if (!si) { Error("FillLeaves", "Cannot get streamer info for branch '%s'", GetName()); return; @@ -1543,7 +1578,7 @@ void TBranchElement::FillLeavesCollectionMember(TBuffer& b) // FIXME: This wont work if a pointer to vector is split! TVirtualCollectionProxy::TPushPop helper(GetCollectionProxy(), fObject); // Note: We cannot pop the proxy here because we need it for the i/o. - TStreamerInfo* si = (TStreamerInfo*)GetInfoImp(); + TStreamerInfo* si = static_cast(GetInfoImp()); if (!si) { Error("FillLeaves", "Cannot get streamer info for branch '%s'", GetName()); return; @@ -1574,7 +1609,7 @@ void TBranchElement::FillLeavesAssociativeCollectionMember(TBuffer& b) // FIXME: This wont work if a pointer to vector is split! TVirtualCollectionProxy::TPushPop helper(GetCollectionProxy(), fObject); // Note: We cannot pop the proxy here because we need it for the i/o. - TStreamerInfo* si = (TStreamerInfo*)GetInfoImp(); + TStreamerInfo* si = static_cast(GetInfoImp()); if (!si) { Error("FillLeaves", "Cannot get streamer info for branch '%s'", GetName()); return; @@ -1603,7 +1638,7 @@ void TBranchElement::FillLeavesClones(TBuffer& b) return; } - TClonesArray* clones = (TClonesArray*) fObject; + TClonesArray* clones = reinterpret_cast(fObject); Int_t n = clones->GetEntriesFast(); if (n > fMaximum) { fMaximum = n; @@ -1627,15 +1662,15 @@ void TBranchElement::FillLeavesClonesMember(TBuffer& b) return; } - TClonesArray* clones = (TClonesArray*) fObject; + TClonesArray* clones = reinterpret_cast(fObject); Int_t n = clones->GetEntriesFast(); - TStreamerInfo* si = (TStreamerInfo*)GetInfoImp(); + TStreamerInfo* si = static_cast(GetInfoImp()); if (!si) { Error("FillLeaves", "Cannot get streamer info for branch '%s'", GetName()); return; } - char **arr = (char **)clones->GetObjectRef(nullptr); + char **arr = reinterpret_cast(clones->GetObjectRef(nullptr)); char **end = arr + n; b.ApplySequenceVecPtr(*fFillActionSequence,arr,end); } @@ -1661,7 +1696,7 @@ void TBranchElement::FillLeavesCustomStreamer(TBuffer& b) // pointers are handled correctly later. if (TestBit(kBranchObject)) { - b.MapObject((TObject*) fObject); + b.MapObject(reinterpret_cast(fObject)); } else if (TestBit(kBranchAny)) { b.MapObject(fObject, fBranchClass); } @@ -1720,7 +1755,7 @@ void TBranchElement::FillLeavesMemberCounter(TBuffer& b) b.ApplySequence(*fFillActionSequence, fObject); // Int_t n = si->WriteBufferAux(b, &fObject, fID, 1, 0, 0); - Int_t n = *(Int_t*)(fObject + si->TStreamerInfo::GetElementOffset(fID)); // or GetInfoImp()->GetTypedValue(&fObject, fID, j, -1); + Int_t n = *reinterpret_cast(fObject + si->TStreamerInfo::GetElementOffset(fID)); // or GetInfoImp()->GetTypedValue(&fObject, fID, j, -1); if (n > fMaximum) { fMaximum = n; } @@ -1745,7 +1780,7 @@ void TBranchElement::FillLeavesMember(TBuffer& b) } if (TestBit(kBranchObject)) { - b.MapObject((TObject*) fObject); + b.MapObject(reinterpret_cast(fObject)); } else if (TestBit(kBranchAny)) { b.MapObject(fObject, fBranchClass); } @@ -1815,7 +1850,7 @@ TBranch* TBranchElement::FindBranch(const char *name) TBranch* branch = nullptr; Int_t nbranches = fBranches.GetEntries(); for(Int_t i = 0; i < nbranches; ++i) { - branch = (TBranch*) fBranches.UncheckedAt(i); + branch = static_cast(fBranches.UncheckedAt(i)); const char *brname = branch->GetName(); UInt_t brlen = strlen(brname); @@ -1854,7 +1889,7 @@ TBranch* TBranchElement::FindBranch(const char *name) TObject *obj = fBranches.UncheckedAt(i); if(obj->IsA() != TBranchElement :: Class() ) continue; - TBranchElement *br = (TBranchElement*)obj; + TBranchElement *br = static_cast(obj); TVirtualStreamerInfo* si = br->GetInfoImp(); if (si && br->GetID() >= 0) { TStreamerElement* se = si->GetElement(br->GetID()); @@ -1879,7 +1914,7 @@ TLeaf* TBranchElement::FindLeaf(const char *name) if( br->IsA() != TBranchElement::Class() ) return nullptr; - TBranchElement *parent = (TBranchElement*)br; + TBranchElement *parent = static_cast(br); if (parent==this || parent->GetID()<0 ) return nullptr; TVirtualStreamerInfo* si = parent->GetInfoImp(); @@ -1891,7 +1926,7 @@ TLeaf* TBranchElement::FindLeaf(const char *name) if( br->IsA() != TBranchElement::Class() ) return nullptr; - TBranchElement *grand_parent = (TBranchElement*)br; + TBranchElement *grand_parent = static_cast(br); std::string longname( grand_parent->GetName() ); R__CleanName(longname); @@ -1900,7 +1935,7 @@ TLeaf* TBranchElement::FindLeaf(const char *name) std::string leafname( GetListOfLeaves()->At(0)->GetName() ); if ( longname == leafname ) { - return (TLeaf*)GetListOfLeaves()->At(0); + return static_cast(GetListOfLeaves()->At(0)); } } return leaf; @@ -1934,7 +1969,7 @@ char* TBranchElement::GetAddress() const // Default to the current StreamerInfo if none are found. TStreamerInfo *TBranchElement::FindOnfileInfo(TClass *valueClass, const TObjArray &branches) const { - TStreamerInfo *localInfo = nullptr; + TVirtualStreamerInfo *localInfo = nullptr; // Search for the correct version. for(auto subbe : TRangeDynCast( branches )) { @@ -1949,22 +1984,22 @@ TStreamerInfo *TBranchElement::FindOnfileInfo(TClass *valueClass, const TObjArra // This is likely sub-optimal as we really should call GetFile but it is non-const. auto file = fDirectory ? fDirectory->GetFile() : nullptr; if (file && file->GetSeekInfo()) { - localInfo = (TStreamerInfo*)file->GetStreamerInfoCache()->FindObject(valueClass->GetName()); + localInfo = static_cast(file->GetStreamerInfoCache()->FindObject(valueClass->GetName())); if (localInfo) { if (valueClass->IsVersioned()) { - localInfo = (TStreamerInfo*)valueClass->GetStreamerInfo(localInfo->GetClassVersion()); + localInfo = valueClass->GetStreamerInfo(localInfo->GetClassVersion()); } else { - localInfo = (TStreamerInfo*)valueClass->FindStreamerInfo(localInfo->GetCheckSum()); + localInfo = valueClass->FindStreamerInfo(localInfo->GetCheckSum()); if (localInfo) { // Now that we found it, we need to make sure it is initialize (Find does not initialize the StreamerInfo). - localInfo = (TStreamerInfo*)valueClass->GetStreamerInfo(localInfo->GetClassVersion()); + localInfo = valueClass->GetStreamerInfo(localInfo->GetClassVersion()); } } } } } if (!localInfo) - localInfo = (TStreamerInfo*)valueClass->GetStreamerInfo(); + localInfo = valueClass->GetStreamerInfo(); if (localInfo) { // See if we need any conversion. @@ -1974,14 +2009,14 @@ TStreamerInfo *TBranchElement::FindOnfileInfo(TClass *valueClass, const TObjArra // For TClonesArray, the rest of the code probably does not support change in // value class, but if it does, we would have to look up the target value class // in the TClonesArray instance. - // if (type == 3 && instance) targetValueClass = ((TClonesArray*)instance)->GetClass(); + // if (type == 3 && instance) targetValueClass = (reinterpret_cast(instance))->GetClass(); if (targetValueClass && localInfo->GetClass() != targetValueClass) { - localInfo = (TStreamerInfo*)targetValueClass->GetConversionStreamerInfo(localInfo->GetClass(), - localInfo->GetClassVersion()); + localInfo = targetValueClass->GetConversionStreamerInfo(localInfo->GetClass(), + localInfo->GetClassVersion()); } } - return localInfo; + return static_cast(localInfo); } namespace { @@ -2005,7 +2040,7 @@ void GatherArtificialElements(const TObjArray &branches, TStreamerInfoActions::T ename = ename.Remove(pos); } - TBranchElement *be = (TBranchElement*)branches.FindObject(ename); + TBranchElement *be = static_cast(branches.FindObject(ename)); if (nextel->IsA() == TStreamerArtificial::Class() && be == nullptr) { @@ -2025,7 +2060,7 @@ void GatherArtificialElements(const TObjArray &branches, TStreamerInfoActions::T if (subprefix.Length() && subprefix[subprefix.Length()-1] == '.') subprefix.Remove(subprefix.Length()-1); - be = (TBranchElement*)branches.FindObject(subprefix); + be = static_cast(branches.FindObject(subprefix)); if (be) { // There is at least 'one' base class branch all with the same name, so let's find the // right one. @@ -2037,7 +2072,7 @@ void GatherArtificialElements(const TObjArray &branches, TStreamerInfoActions::T be = nullptr; Int_t nbranches = branches.GetEntriesFast(); for (Int_t bi = 0; bi < nbranches; ++bi) { - TBranchElement* branch = (TBranchElement*) branches[bi]; + TBranchElement* branch = static_cast(branches[bi]); if (subprefix != branch->GetName()) continue; if (0 == branch->GetExpectedType(expectedClass,expectedType) @@ -2071,7 +2106,7 @@ void GatherArtificialElements(const TObjArray &branches, TStreamerInfoActions::T auto nbranches = search->GetEntriesFast(); bool foundRelatedSplit = false; for (Int_t bi = 0; bi < nbranches; ++bi) { - TBranchElement* subbe = (TBranchElement*)search->At(bi); + TBranchElement* subbe = static_cast(search->At(bi)); bool matchSubPrefix = strncmp(subbe->GetFullName(), subprefix.Data(), subprefix.Length()) == 0; if (!foundRelatedSplit) foundRelatedSplit = matchSubPrefix; @@ -2090,9 +2125,9 @@ void GatherArtificialElements(const TObjArray &branches, TStreamerInfoActions::T } if (!nextinfo) { - nextinfo = (TStreamerInfo *)elementClass->GetStreamerInfo(); + nextinfo = static_cast(elementClass->GetStreamerInfo()); if (elementClass->GetCollectionProxy() && elementClass->GetCollectionProxy()->GetValueClass()) { - nextinfo = (TStreamerInfo *)elementClass->GetCollectionProxy()->GetValueClass()->GetStreamerInfo(); // NOTE: need to find the right version + nextinfo = static_cast(elementClass->GetCollectionProxy()->GetValueClass()->GetStreamerInfo()); // NOTE: need to find the right version } } ids.emplace_back(nextinfo, offset + nextel->GetOffset()); @@ -2151,7 +2186,7 @@ void TBranchElement::SetupInfo() { if ( (cl->Property() & kIsAbstract) && cl == targetClass) { - TBranchElement *parent = (TBranchElement*)GetMother()->GetSubBranch(this); + TBranchElement *parent = static_cast(GetMother()->GetSubBranch(this)); if (parent && parent != this && !parent->GetClass()->IsLoaded() ) { // Our parent's class is emulated and we represent an abstract class. // and the target class has not been set explicitly. @@ -2166,9 +2201,9 @@ void TBranchElement::SetupInfo() } } if( targetClass != cl ) { - fInfo = (TStreamerInfo*)targetClass->GetConversionStreamerInfo( cl, fClassVersion ); + fInfo = static_cast(targetClass->GetConversionStreamerInfo( cl, fClassVersion )); } else { - fInfo = (TStreamerInfo*)cl->GetStreamerInfo(fClassVersion); + fInfo = static_cast(cl->GetStreamerInfo(fClassVersion)); } } @@ -2176,19 +2211,19 @@ void TBranchElement::SetupInfo() // Check to see if the class code was unloaded/reloaded // since we were created. R__LOCKGUARD(gInterpreterMutex); - if (fCheckSum && (cl->IsForeign() || (!cl->IsLoaded() && (fClassVersion == 1) && cl->GetStreamerInfos()->At(1) && (fCheckSum != ((TVirtualStreamerInfo*) cl->GetStreamerInfos()->At(1))->GetCheckSum())))) { + if (fCheckSum && (cl->IsForeign() || (!cl->IsLoaded() && (fClassVersion == 1) && cl->GetStreamerInfos()->At(1) && (fCheckSum != static_cast(cl->GetStreamerInfos()->At(1))->GetCheckSum())))) { // Try to compensate for a class that got unloaded on us. // Search through the streamer infos by checksum // and take the first match. TStreamerInfo* info; if( targetClass != cl ) - info = (TStreamerInfo*)targetClass->FindConversionStreamerInfo( cl, fCheckSum ); + info = static_cast(targetClass->FindConversionStreamerInfo( cl, fCheckSum )); else { - info = (TStreamerInfo*)cl->FindStreamerInfo( fCheckSum ); + info = static_cast(cl->FindStreamerInfo( fCheckSum )); if (info) { // Now that we found it, we need to make sure it is initialize (Find does not initialize the StreamerInfo). - info = (TStreamerInfo*)cl->GetStreamerInfo(info->GetClassVersion()); + info = static_cast(cl->GetStreamerInfo(info->GetClassVersion())); } } if( info ) { @@ -2237,7 +2272,7 @@ void TBranchElement::InitInfo() auto SetOnfileObject = [this](TStreamerInfo *info) { Int_t arrlen = 1; if (fType==31 || fType==41) { - TLeaf *leaf = (TLeaf*)fLeaves.At(0); + TLeaf *leaf = static_cast(fLeaves.At(0)); if (leaf) { arrlen = leaf->GetMaximum(); } @@ -2269,13 +2304,13 @@ void TBranchElement::InitInfo() Ssiz_t lastdot = fullname.Last('.'); if (lastdot == TString::kNPOS) { // No prefix or index, thus this is a first level branch - TBranchElement* subbranch = (TBranchElement*)branches->At(0); + TBranchElement* subbranch = static_cast(branches->At(0)); if (!subbranch->fInfo) subbranch->SetupInfo(); } else { TString &thisprefix = fullname.Remove(lastdot + 1); // Mod fullname and 'rename' the variable. for(Int_t i = index - 1; i >= 0; --i) { - TBranchElement* subbranch = (TBranchElement*)branches->At(i); + TBranchElement* subbranch = static_cast(branches->At(i)); TString subbranch_name(subbranch->GetFullName()); if ( ! subbranch_name.BeginsWith(thisprefix)) { // We moved to another data member (of the enclosing class) @@ -2286,7 +2321,7 @@ void TBranchElement::InitInfo() subbranch->SetupInfo(); } for(Int_t i = index; i < nbranches; ++i) { - TBranchElement* subbranch = (TBranchElement*)branches->At(i); + TBranchElement* subbranch = static_cast(branches->At(i)); TString subbranch_name(subbranch->GetFullName()); if ( ! subbranch_name.BeginsWith(thisprefix)) { lastindex = i - 1; @@ -2301,7 +2336,7 @@ void TBranchElement::InitInfo() if (lastdot != TString::kNPOS) { TString &thisprefix = fullname.Remove(lastdot + 1); // Mod fullname and 'rename' the variable. for(Int_t i = 0; i < nbranches; ++i) { - TBranchElement* subbranch = (TBranchElement*)branches->At(i); + TBranchElement* subbranch = static_cast(branches->At(i)); TString subbranch_name(subbranch->GetFullName()); if ( ! subbranch_name.BeginsWith(thisprefix)) { lastindex = i - 1; @@ -2311,7 +2346,7 @@ void TBranchElement::InitInfo() } } for (Int_t i = firstindex; i <= lastindex; ++i) { - TBranchElement* subbranch = (TBranchElement*)branches->At(i); + TBranchElement* subbranch = static_cast(branches->At(i)); bool match = false; if (this != subbranch) { @@ -2605,7 +2640,7 @@ TClass* TBranchElement::GetCurrentClass() return cl; } - TStreamerInfo* brInfo = (TStreamerInfo*)GetInfoImp(); + TStreamerInfo* brInfo = static_cast(GetInfoImp()); if (!brInfo) { cl = TClass::GetClass(GetClassName()); R__ASSERT(cl && cl->GetCollectionProxy()); @@ -2624,7 +2659,7 @@ TClass* TBranchElement::GetCurrentClass() return nullptr; } TStreamerElement* currentStreamerElement = brInfo->GetElement(GetID()); - TDataMember* dm = (TDataMember*) motherCl->GetListOfDataMembers()->FindObject(currentStreamerElement->GetName()); + TDataMember* dm = static_cast(motherCl->GetListOfDataMembers()->FindObject(currentStreamerElement->GetName())); TString newType; if (!dm) { @@ -2632,7 +2667,7 @@ TClass* TBranchElement::GetCurrentClass() if (!motherCl->IsLoaded()) { TVirtualStreamerInfo* newInfo = motherCl->GetStreamerInfo(); if (newInfo != brInfo) { - TStreamerElement* newElems = (TStreamerElement*) newInfo->GetElements()->FindObject(currentStreamerElement->GetName()); + TStreamerElement* newElems = static_cast(newInfo->GetElements()->FindObject(currentStreamerElement->GetName())); if (newElems) { if (newElems->GetClassPointer()) newType = newElems->GetClassPointer()->GetName(); @@ -2672,6 +2707,7 @@ TClass* TBranchElement::GetCurrentClass() Int_t TBranchElement::GetEntry(Long64_t entry, Int_t getall) { // Remember which entry we are reading. + auto prevEntry = fReadEntry; fReadEntry = entry; // If our tree has a branch ref, make it remember the entry and @@ -2711,27 +2747,17 @@ Int_t TBranchElement::GetEntry(Long64_t entry, Int_t getall) } nbytes += nb; } - switch(fSTLtype) { - case ROOT::kSTLset: - case ROOT::kSTLmultiset: - case ROOT::kSTLunorderedset: - case ROOT::kSTLunorderedmultiset: - case ROOT::kSTLmap: - case ROOT::kSTLmultimap: - case ROOT::kSTLunorderedmap: - case ROOT::kSTLunorderedmultimap: - break; - default: - ValidateAddress(); // There is no ReadLeave for this node, so we need to do the validation here. - for (Int_t i = 0; i < nbranches; ++i) { - TBranch* branch = (TBranch*) fBranches.UncheckedAt(i); - Int_t nb = branch->GetEntry(entry, getall); - if (nb < 0) { - return nb; - } - nbytes += nb; + if (!IsAssociativeContainer(fSTLtype)) { + ValidateAddress(); // There is no ReadLeave for the node of a top level split object, so we need to do the + // validation here. + for (Int_t i = 0; i < nbranches; ++i) { + TBranch* branch = static_cast(fBranches.UncheckedAt(i)); + Int_t nb = branch->GetEntry(entry, getall); + if (nb < 0) { + return nb; } - break; + nbytes += nb; + } } if (!TestBit(kDecomposedObj) && fReadActionSequence && !fReadActionSequence->fActions.empty()) { if (fType == 3) { @@ -2741,13 +2767,13 @@ Int_t TBranchElement::GetEntry(Long64_t entry, Int_t getall) auto ndata = GetNdata(); - TClonesArray* clones = (TClonesArray*) fObject; + TClonesArray* clones = reinterpret_cast(fObject); if (clones->IsZombie()) { return -1; } R__PushCache onfileObject(b, fOnfileObject, ndata); - char **arr = (char **)clones->GetObjectRef(); + char **arr = reinterpret_cast(clones->GetObjectRef()); char **end = arr + fNdata; b.ApplySequenceVecPtr(*fReadActionSequence,arr,end); @@ -2774,18 +2800,29 @@ Int_t TBranchElement::GetEntry(Long64_t entry, Int_t getall) } } else { // -- Terminal branch. + if (fBranchCount && (fBranchCount->GetReadEntry() != entry)) { Int_t nb = fBranchCount->TBranch::GetEntry(entry, getall); + if (nb < 0) + return nb; + nbytes += nb; + } + // For associative containers, the count branch is actually + // reading the subbranches (including this one) and in the case + // of a compiled proxy the necessary staging area is only available + // during the call to the count branch GetEntry. + // We detect this code path by checking the position of the cursor, + // which is explicitly reset by the count branch's GetEntry. + // One down-side, if the user call twice GetEntry on the same entry, + // the second call will not re-read the sub-branches (unlike all the other + // types of branches). + if (!fBranchCount || (prevEntry != entry) || !IsAssociativeContainer(fBranchCount->fSTLtype)) { + Int_t nb = TBranch::GetEntry(entry, getall); if (nb < 0) { return nb; } nbytes += nb; } - Int_t nb = TBranch::GetEntry(entry, getall); - if (nb < 0) { - return nb; - } - nbytes += nb; } if (R__unlikely(fTree->Debug() > 0)) { @@ -3020,29 +3057,30 @@ T TBranchElement::GetTypedValue(Int_t j, Int_t len, bool subarr) const } if (fType == 31) { - TClonesArray* clones = (TClonesArray*) object; + TClonesArray* clones = reinterpret_cast(object); if (subarr) { return GetInfoImp()->GetTypedValueClones(clones, prID, j, len, fOffset); } return GetInfoImp()->GetTypedValueClones(clones, prID, j/len, j%len, fOffset); } else if (fType == 41) { - TVirtualCollectionProxy::TPushPop helper(((TBranchElement*) this)->GetCollectionProxy(), object); + TVirtualCollectionProxy::TPushPop helper(const_cast(this)->GetCollectionProxy(), object); if( fSplitLevel < TTree::kSplitCollectionOfPointers ) { if (subarr) - return GetInfoImp()->GetTypedValueSTL(((TBranchElement*) this)->GetCollectionProxy(), prID, j, len, fOffset); + return GetInfoImp()->GetTypedValueSTL(const_cast(this)->GetCollectionProxy(), prID, j, len, fOffset); - return GetInfoImp()->GetTypedValueSTL(((TBranchElement*) this)->GetCollectionProxy(), prID, j/len, j%len, fOffset); + return GetInfoImp()->GetTypedValueSTL(const_cast(this)->GetCollectionProxy(), prID, j/len, j%len, fOffset); } else { if (subarr) - return GetInfoImp()->GetTypedValueSTLP(((TBranchElement*) this)->GetCollectionProxy(), prID, j, len, fOffset); - return GetInfoImp()->GetTypedValueSTLP(((TBranchElement*) this)->GetCollectionProxy(), prID, j/len, j%len, fOffset); + return GetInfoImp()->GetTypedValueSTLP(const_cast(this)->GetCollectionProxy(), prID, j, len, fOffset); + return GetInfoImp()->GetTypedValueSTLP(const_cast(this)->GetCollectionProxy(), prID, j/len, j%len, fOffset); } } else { - if (GetInfoImp()) { - return GetInfoImp()->GetTypedValue(object, prID, j, -1); + auto info = GetInfoImp(); + if (info) { + return info->GetTypedValue(object, prID, j, -1); } return 0; } @@ -3056,10 +3094,12 @@ void* TBranchElement::GetValuePointer() const { ValidateAddress(); + TStreamerInfo *info = nullptr; Int_t prID = fID; char *object = fObject; if (TestBit(kCache)) { - if (GetInfoImp()->GetElements()->At(fID)->TestBit(TStreamerElement::kRepeat)) { + info = GetInfoImp(); + if (info->GetElements()->At(fID)->TestBit(TStreamerElement::kRepeat)) { prID = fID+1; } else if (fOnfileObject) { object = fOnfileObject->GetObjectAt(0); @@ -3112,8 +3152,10 @@ void* TBranchElement::GetValuePointer() const return object; } else { //return GetInfoImp()->GetValue(object,fID,j,-1); - if (!GetInfoImp() || !object) return nullptr; - char **val = (char**)(object+GetInfoImp()->TStreamerInfo::GetElementOffset(prID)); + if (!info) + info = GetInfoImp(); + if (!info || !object) return nullptr; + char **val = reinterpret_cast(object+info->TStreamerInfo::GetElementOffset(prID)); return *val; } } @@ -3173,7 +3215,8 @@ void TBranchElement::InitializeOffsets() return; } // Make sure we can instantiate our class streamer info. - if (!GetInfoImp()) { + TStreamerInfo *info = GetInfoImp(); + if (!info) { Warning("InitializeOffsets", "No streamer info available for branch: %s of class: %s", GetName(), fBranchClass.GetClass()->GetName()); fInitOffsets = true; return; @@ -3191,19 +3234,18 @@ void TBranchElement::InitializeOffsets() if (fID > -1) { // -- Branch is *not* a top-level branch. // Instead of the streamer info class, we want the class of our - // specific element in the streamer info. We could be a data + // specific element in the streamer info. We could be a data // member of a base class or a split class, in which case our // streamer info will be for our containing sub-object, while // we are actually a different type. - TVirtualStreamerInfo* si = GetInfoImp(); // Note: We tested to make sure the streamer info was available previously. - if (!si->IsCompiled()) { + if (!info->IsCompiled()) { Warning("InitializeOffsets", "Streamer info for branch: %s has no elements array!", GetName()); fInitOffsets = true; return; } // FIXME: Check that fID is in range. - branchElem = si->GetElement(fID); + branchElem = info->GetElement(fID); if (!branchElem) { Warning("InitializeOffsets", "Cannot get streamer element for branch: %s!", GetName()); fInitOffsets = true; @@ -3211,8 +3253,8 @@ void TBranchElement::InitializeOffsets() } else if (branchElem->TestBit(TStreamerElement::kRepeat)) { // If we have a repeating streamerElement, use the next // one as it actually hold the 'real' data member('s offset) - if (si->GetElement(fID+1)) { - branchElem = si->GetElement(fID+1); + if (info->GetElement(fID+1)) { + branchElem = info->GetElement(fID+1); } } localOffset = branchElem->GetOffset(); @@ -3300,7 +3342,7 @@ void TBranchElement::InitializeOffsets() iter != end; ++iter) { TStreamerInfoActions::TConfiguration *config = iter->fConfiguration; UInt_t id = config->fElemId; - TStreamerElement *e = (TStreamerElement*)config->fInfo->GetElements()->At(id); + TStreamerElement *e = static_cast(config->fInfo->GetElements()->At(id)); if (e && !e->TestBit(TStreamerElement::kCache)) { subBranchElement = e; alternateElement = true; @@ -3563,7 +3605,7 @@ void TBranchElement::InitializeOffsets() TStreamerInfo *subInfo = subBranch->GetInfoImp(); //if (subInfo && subBranch->TestBit(kCache)) { // subInfo->GetElements()->At(subBranch->GetID())->TestBit(TStreamerElement::kCache)) { if (subBranchElement->TestBit(TStreamerElement::kCache)) { - pClass = ((TStreamerElement*)subInfo->GetElements()->At(0))->GetClassPointer(); + pClass = static_cast(subInfo->GetElements()->At(0))->GetClassPointer(); } // FIXME: Do we need the other base class tests here? if (!pClass) { @@ -3574,7 +3616,7 @@ void TBranchElement::InitializeOffsets() if (pClass->Property() & kIsAbstract) { // the class is abstract, let see if the - TBranchElement *parent = (TBranchElement*)GetMother()->GetSubBranch(this); + TBranchElement *parent = static_cast(GetMother()->GetSubBranch(this)); if (parent && parent != this && !parent->GetClass()->IsLoaded() ) { // Our parent's class is emulated and we represent an abstract class. // and the target class has not been set explicitly. @@ -3797,7 +3839,7 @@ bool TBranchElement::IsFolder() const bool TBranchElement::IsMissingCollection() const { bool ismissing = false; - TBasket* basket = (TBasket*) fBaskets.UncheckedAt(fReadBasket); + TBasket* basket = static_cast(fBaskets.UncheckedAt(fReadBasket)); if (basket && fTree) { Long64_t entry = fTree->GetReadEntry(); Long64_t first = fBasketEntry[fReadBasket]; @@ -3868,7 +3910,7 @@ void TBranchElement::Print(Option_t* option) const TBranchElement *parent = dynamic_cast(GetMother()->GetSubBranch(this)); Int_t ind = parent ? parent->GetListOfBranches()->IndexOf(this) : -1; - TVirtualStreamerInfo *info = ((TBranchElement*)this)->GetInfoImp(); + TVirtualStreamerInfo *info = const_cast(this)->GetInfoImp(); Printf("%-16s %2d %4d %-16s %-16s %8x %8x %p %p%s\n", info ? info->GetName() : "StreamerInfo unavailable", GetID(), GetType(), @@ -3876,19 +3918,19 @@ void TBranchElement::Print(Option_t* option) const (fBranchOffset&&parent && ind>=0) ? parent->fBranchOffset[ind] : 0, GetOffset(), GetObject(), fOnfileObject, TestBit(kOwnOnfileObj) ? " (owned)" : ""); for (Int_t i = 0; i < nbranches; ++i) { - TBranchElement* subbranch = (TBranchElement*)fBranches.At(i); + TBranchElement* subbranch = static_cast(fBranches.At(i)); subbranch->Print("debugAddressSub"); } return; } if (strncmp(option,"debugInfo",length("debugInfo"))==0) { Printf("Branch %s uses:",GetName()); - if (fID>=0) { + TStreamerInfo *localInfo = GetInfoImp(); + if (fID>= 0) { // GetInfoImp()->GetElement(fID)->ls(); // for(UInt_t i=0; i< fIDs.size(); ++i) { // GetInfoImp()->GetElement(fIDs[i])->ls(); // } - TStreamerInfo *localInfo = GetInfoImp(); if (fType == 3 || fType == 4) { // Search for the correct version. localInfo = FindOnfileInfo(fClonesClass, fBranches); @@ -3901,8 +3943,7 @@ void TBranchElement::Print(Option_t* option) const if (fReadActionSequence) fReadActionSequence->Print(option); Printf(" with write actions:"); if (fFillActionSequence) fFillActionSequence->Print(option); - } else if (!fNewIDs.empty() && GetInfoImp()) { - TStreamerInfo *localInfo = GetInfoImp(); + } else if (!fNewIDs.empty() && localInfo) { if (fType == 3 || fType == 4) { // Search for the correct version. localInfo = FindOnfileInfo(fClonesClass, fBranches); @@ -3916,7 +3957,7 @@ void TBranchElement::Print(Option_t* option) const TString suboption = "debugInfoSub"; suboption += (option+length("debugInfo")); for (Int_t i = 0; i < nbranches; ++i) { - TBranchElement* subbranch = (TBranchElement*)fBranches.At(i); + TBranchElement* subbranch = static_cast(fBranches.At(i)); subbranch->Print(suboption); } Printf(" "); @@ -3936,7 +3977,7 @@ void TBranchElement::Print(Option_t* option) const TBranch::Print(option); } for (Int_t i=0;i(fBranches.At(i)); branch->Print(option); } } else { @@ -3987,11 +4028,11 @@ void TBranchElement::PrintValue(Int_t lenmax) const } if (fStreamerType > 20) { atype -= 20; - TLeafElement* leaf = (TLeafElement*) fLeaves.UncheckedAt(0); + TLeafElement* leaf = static_cast(fLeaves.UncheckedAt(0)); n = n * leaf->GetLenStatic(); } - if (GetInfoImp()) { - GetInfoImp()->PrintValue(GetName(), fAddress, atype, n, lenmax); + if (info) { + info->PrintValue(GetName(), fAddress, atype, n, lenmax); } return; } else if (fType <= 2) { @@ -3999,14 +4040,14 @@ void TBranchElement::PrintValue(Int_t lenmax) const // FIXME: This should probably be < 60 instead. if ((fStreamerType > 40) && (fStreamerType < 55)) { Int_t atype = fStreamerType - 20; - TBranchElement* counterElement = (TBranchElement*) fBranchCount; + TBranchElement* counterElement = static_cast(fBranchCount); Int_t n = (Int_t) counterElement->GetValue(0, 0); - if (GetInfoImp()) { - GetInfoImp()->PrintValue(GetName(), fAddress, atype, n, lenmax); + if (info) { + info->PrintValue(GetName(), fAddress, atype, n, lenmax); } } else { - if (GetInfoImp()) { - GetInfoImp()->PrintValue(GetName(), object, prID, -1, lenmax); + if (info) { + info->PrintValue(GetName(), object, prID, -1, lenmax); } } return; @@ -4014,18 +4055,18 @@ void TBranchElement::PrintValue(Int_t lenmax) const } else if (fType == 3) { printf(" %-15s = %d\n", GetName(), fNdata); } else if (fType == 31) { - TClonesArray* clones = (TClonesArray*) object; - if (GetInfoImp()) { - GetInfoImp()->PrintValueClones(GetName(), clones, prID, fOffset, lenmax); + TClonesArray* clones = reinterpret_cast(object); + if (info) { + info->PrintValueClones(GetName(), clones, prID, fOffset, lenmax); } } else if (fType == 41) { - TVirtualCollectionProxy::TPushPop helper(((TBranchElement*) this)->GetCollectionProxy(), object); - if (GetInfoImp()) { - GetInfoImp()->PrintValueSTL(GetName(), ((TBranchElement*) this)->GetCollectionProxy(), prID, fOffset, lenmax); + TVirtualCollectionProxy::TPushPop helper(const_cast(this)->GetCollectionProxy(), object); + if (info) { + info->PrintValueSTL(GetName(), const_cast(this)->GetCollectionProxy(), prID, fOffset, lenmax); } } else { - if (GetInfoImp()) { - GetInfoImp()->PrintValue(GetName(), object, prID, -1, lenmax); + if (info) { + info->PrintValue(GetName(), object, prID, -1, lenmax); } } } @@ -4048,7 +4089,7 @@ void TBranchElement::ReadLeavesMakeClass(TBuffer& b) if (fType == 3 || fType == 4) { // Top level branch of a TClonesArray. - Int_t *n = (Int_t*) fAddress; + Int_t *n = reinterpret_cast(fAddress); b >> n[0]; if ((n[0] < 0) || (n[0] > fMaximum)) { if (IsMissingCollection()) { @@ -4060,23 +4101,14 @@ void TBranchElement::ReadLeavesMakeClass(TBuffer& b) } } fNdata = n[0]; - if (fType == 4) { + if (fType == 4 && IsAssociativeContainer(fSTLtype)) { Int_t nbranches = fBranches.GetEntriesFast(); - switch(fSTLtype) { - case ROOT::kSTLset: - case ROOT::kSTLmultiset: - case ROOT::kSTLmap: - case ROOT::kSTLmultimap: - for (Int_t i=0; iGetEntry(GetReadEntry(), 1); - if (nb < 0) { - break; - } - } - break; - default: + for (Int_t i=0; i(fBranches[i]); + Int_t nb = branch->GetEntry(GetReadEntry(), 1); + if (nb < 0) { break; + } } } return; @@ -4092,82 +4124,82 @@ void TBranchElement::ReadLeavesMakeClass(TBuffer& b) if (atype>40) { atype -= 40; if (!fBranchCount2) return; - const char *len_where = (char*)fBranchCount2->fAddress; + const char *len_where = fBranchCount2->fAddress; if (!len_where) return; Int_t len_atype = fBranchCount2->fStreamerType; Int_t length; Int_t k; Char_t isArray; for( k=0; k(fAddress))[k]); delete [] *where; *where = nullptr; switch(len_atype) { - case 1: {length = ((Char_t*) len_where)[k]; break;} - case 2: {length = ((Short_t*) len_where)[k]; break;} - case 3: {length = ((Int_t*) len_where)[k]; break;} - case 4: {length = ((Long_t*) len_where)[k]; break;} - //case 5: {length = ((Float_t*) len_where)[k]; break;} - case 6: {length = ((Int_t*) len_where)[k]; break;} - //case 8: {length = ((Double_t*)len_where)[k]; break;} - case 11: {length = ((UChar_t*) len_where)[k]; break;} - case 12: {length = ((UShort_t*) len_where)[k]; break;} - case 13: {length = ((UInt_t*) len_where)[k]; break;} - case 14: {length = ((ULong_t*) len_where)[k]; break;} - case 15: {length = ((UInt_t*) len_where)[k]; break;} - case 16: {length = ((Long64_t*) len_where)[k]; break;} - case 17: {length = ((ULong64_t*)len_where)[k]; break;} - case 18: {length = ((bool*) len_where)[k]; break;} + case 1: {length = (reinterpret_cast(len_where))[k]; break;} + case 2: {length = (reinterpret_cast(len_where))[k]; break;} + case 3: {length = (reinterpret_cast(len_where))[k]; break;} + case 4: {length = (reinterpret_cast(len_where))[k]; break;} + //case 5: {length = (reinterpret_cast(len_where))[k]; break;} + case 6: {length = (reinterpret_cast(len_where))[k]; break;} + //case 8: {length = (reinterpret_cast(len_where))[k]; break;} + case 11: {length = (reinterpret_cast(len_where))[k]; break;} + case 12: {length = (reinterpret_cast(len_where))[k]; break;} + case 13: {length = (reinterpret_cast(len_where))[k]; break;} + case 14: {length = (reinterpret_cast(len_where))[k]; break;} + case 15: {length = (reinterpret_cast(len_where))[k]; break;} + case 16: {length = (reinterpret_cast(len_where))[k]; break;} + case 17: {length = (reinterpret_cast(len_where))[k]; break;} + case 18: {length = (reinterpret_cast(len_where))[k]; break;} default: continue; } b >> isArray; if (length <= 0) continue; if (isArray == 0) continue; switch (atype) { - case 1: {*where=new char[sizeof(Char_t)*length]; b.ReadFastArray((Char_t*) *where, length); break;} - case 2: {*where=new char[sizeof(Short_t)*length]; b.ReadFastArray((Short_t*) *where, length); break;} - case 3: {*where=new char[sizeof(Int_t)*length]; b.ReadFastArray((Int_t*) *where, length); break;} - case 4: {*where=new char[sizeof(Long_t)*length]; b.ReadFastArray((Long_t*) *where, length); break;} - case 5: {*where=new char[sizeof(Float_t)*length]; b.ReadFastArray((Float_t*) *where, length); break;} - case 6: {*where=new char[sizeof(Int_t)*length]; b.ReadFastArray((Int_t*) *where, length); break;} - case 8: {*where=new char[sizeof(Double_t)*length]; b.ReadFastArray((Double_t*)*where, length); break;} - case 11: {*where=new char[sizeof(UChar_t)*length]; b.ReadFastArray((UChar_t*) *where, length); break;} - case 12: {*where=new char[sizeof(UShort_t)*length]; b.ReadFastArray((UShort_t*)*where, length); break;} - case 13: {*where=new char[sizeof(UInt_t)*length]; b.ReadFastArray((UInt_t*) *where, length); break;} - case 14: {*where=new char[sizeof(ULong_t)*length]; b.ReadFastArray((ULong_t*) *where, length); break;} - case 15: {*where=new char[sizeof(UInt_t)*length]; b.ReadFastArray((UInt_t*) *where, length); break;} - case 16: {*where=new char[sizeof(Long64_t)*length]; b.ReadFastArray((Long64_t*) *where, length); break;} - case 17: {*where=new char[sizeof(ULong64_t)*length]; b.ReadFastArray((ULong64_t*)*where, length); break;} - case 18: {*where=new char[sizeof(bool)*length]; b.ReadFastArray((bool*) *where, length); break;} + case 1: {*where=new char[sizeof(Char_t)*length]; b.ReadFastArray(reinterpret_cast(*where), length); break;} + case 2: {*where=new char[sizeof(Short_t)*length]; b.ReadFastArray(reinterpret_cast(*where), length); break;} + case 3: {*where=new char[sizeof(Int_t)*length]; b.ReadFastArray(reinterpret_cast(*where), length); break;} + case 4: {*where=new char[sizeof(Long_t)*length]; b.ReadFastArray(reinterpret_cast(*where), length); break;} + case 5: {*where=new char[sizeof(Float_t)*length]; b.ReadFastArray(reinterpret_cast(*where), length); break;} + case 6: {*where=new char[sizeof(Int_t)*length]; b.ReadFastArray(reinterpret_cast(*where), length); break;} + case 8: {*where=new char[sizeof(Double_t)*length]; b.ReadFastArray(reinterpret_cast(*where), length); break;} + case 11: {*where=new char[sizeof(UChar_t)*length]; b.ReadFastArray(reinterpret_cast(*where), length); break;} + case 12: {*where=new char[sizeof(UShort_t)*length]; b.ReadFastArray(reinterpret_cast(*where), length); break;} + case 13: {*where=new char[sizeof(UInt_t)*length]; b.ReadFastArray(reinterpret_cast(*where), length); break;} + case 14: {*where=new char[sizeof(ULong_t)*length]; b.ReadFastArray(reinterpret_cast(*where), length); break;} + case 15: {*where=new char[sizeof(UInt_t)*length]; b.ReadFastArray(reinterpret_cast(*where), length); break;} + case 16: {*where=new char[sizeof(Long64_t)*length]; b.ReadFastArray(reinterpret_cast(*where), length); break;} + case 17: {*where=new char[sizeof(ULong64_t)*length]; b.ReadFastArray(reinterpret_cast(*where), length); break;} + case 18: {*where=new char[sizeof(bool)*length]; b.ReadFastArray(reinterpret_cast(*where), length); break;} } } return; } if (atype > 20) { atype -= 20; - TLeafElement *leaf = (TLeafElement*)fLeaves.UncheckedAt(0); + TLeafElement *leaf = static_cast(fLeaves.UncheckedAt(0)); n *= leaf->GetLenStatic(); } switch (atype) { - case 1: {b.ReadFastArray((Char_t*) fAddress, n); break;} - case 2: {b.ReadFastArray((Short_t*) fAddress, n); break;} - case 3: {b.ReadFastArray((Int_t*) fAddress, n); break;} - case 4: {b.ReadFastArray((Long_t*) fAddress, n); break;} - case 5: {b.ReadFastArray((Float_t*) fAddress, n); break;} - case 6: {b.ReadFastArray((Int_t*) fAddress, n); break;} - case 8: {b.ReadFastArray((Double_t*)fAddress, n); break;} - case 11: {b.ReadFastArray((UChar_t*) fAddress, n); break;} - case 12: {b.ReadFastArray((UShort_t*)fAddress, n); break;} - case 13: {b.ReadFastArray((UInt_t*) fAddress, n); break;} - case 14: {b.ReadFastArray((ULong_t*) fAddress, n); break;} - case 15: {b.ReadFastArray((UInt_t*) fAddress, n); break;} - case 16: {b.ReadFastArray((Long64_t*)fAddress, n); break;} - case 17: {b.ReadFastArray((ULong64_t*)fAddress, n); break;} - case 18: {b.ReadFastArray((bool*) fAddress, n); break;} + case 1: {b.ReadFastArray(reinterpret_cast(fAddress), n); break;} + case 2: {b.ReadFastArray(reinterpret_cast(fAddress), n); break;} + case 3: {b.ReadFastArray(reinterpret_cast(fAddress), n); break;} + case 4: {b.ReadFastArray(reinterpret_cast(fAddress), n); break;} + case 5: {b.ReadFastArray(reinterpret_cast(fAddress), n); break;} + case 6: {b.ReadFastArray(reinterpret_cast(fAddress), n); break;} + case 8: {b.ReadFastArray(reinterpret_cast(fAddress), n); break;} + case 11: {b.ReadFastArray(reinterpret_cast(fAddress), n); break;} + case 12: {b.ReadFastArray(reinterpret_cast(fAddress), n); break;} + case 13: {b.ReadFastArray(reinterpret_cast(fAddress), n); break;} + case 14: {b.ReadFastArray(reinterpret_cast(fAddress), n); break;} + case 15: {b.ReadFastArray(reinterpret_cast(fAddress), n); break;} + case 16: {b.ReadFastArray(reinterpret_cast(fAddress), n); break;} + case 17: {b.ReadFastArray(reinterpret_cast(fAddress), n); break;} + case 18: {b.ReadFastArray(reinterpret_cast(fAddress), n); break;} case 9: { TVirtualStreamerInfo* si = GetInfoImp(); - TStreamerElement* se = (TStreamerElement*) si->GetElement(fID); - Double_t *xx = (Double_t*) fAddress; + TStreamerElement* se = static_cast(si->GetElement(fID)); + Double_t *xx = reinterpret_cast(fAddress); for (Int_t ii=0;iiGetElement(fID); - Float_t *xx = (Float_t*) fAddress; + TStreamerElement* se = static_cast(si->GetElement(fID)); + Float_t *xx = reinterpret_cast(fAddress); for (Int_t ii=0;iiGetBranch(countname)); + SetBranchCount(static_cast(fTree->GetBranch(countname))); } if (fBranchCount) { n = (Int_t)fBranchCount->GetValue(0,0); @@ -4221,25 +4253,25 @@ void TBranchElement::ReadLeavesMakeClass(TBuffer& b) Char_t isArray; b >> isArray; switch (atype) { - case 1: {b.ReadFastArray((Char_t*) fAddress, n); break;} - case 2: {b.ReadFastArray((Short_t*) fAddress, n); break;} - case 3: {b.ReadFastArray((Int_t*) fAddress, n); break;} - case 4: {b.ReadFastArray((Long_t*) fAddress, n); break;} - case 5: {b.ReadFastArray((Float_t*) fAddress, n); break;} - case 6: {b.ReadFastArray((Int_t*) fAddress, n); break;} - case 8: {b.ReadFastArray((Double_t*)fAddress, n); break;} - case 11: {b.ReadFastArray((UChar_t*) fAddress, n); break;} - case 12: {b.ReadFastArray((UShort_t*)fAddress, n); break;} - case 13: {b.ReadFastArray((UInt_t*) fAddress, n); break;} - case 14: {b.ReadFastArray((ULong_t*) fAddress, n); break;} - case 15: {b.ReadFastArray((UInt_t*) fAddress, n); break;} - case 16: {b.ReadFastArray((Long64_t*) fAddress, n); break;} - case 17: {b.ReadFastArray((ULong64_t*)fAddress, n); break;} - case 18: {b.ReadFastArray((bool*) fAddress, n); break;} + case 1: {b.ReadFastArray(reinterpret_cast(fAddress), n); break;} + case 2: {b.ReadFastArray(reinterpret_cast(fAddress), n); break;} + case 3: {b.ReadFastArray(reinterpret_cast(fAddress), n); break;} + case 4: {b.ReadFastArray(reinterpret_cast(fAddress), n); break;} + case 5: {b.ReadFastArray(reinterpret_cast(fAddress), n); break;} + case 6: {b.ReadFastArray(reinterpret_cast(fAddress), n); break;} + case 8: {b.ReadFastArray(reinterpret_cast(fAddress), n); break;} + case 11: {b.ReadFastArray(reinterpret_cast(fAddress), n); break;} + case 12: {b.ReadFastArray(reinterpret_cast(fAddress), n); break;} + case 13: {b.ReadFastArray(reinterpret_cast(fAddress), n); break;} + case 14: {b.ReadFastArray(reinterpret_cast(fAddress), n); break;} + case 15: {b.ReadFastArray(reinterpret_cast(fAddress), n); break;} + case 16: {b.ReadFastArray(reinterpret_cast(fAddress), n); break;} + case 17: {b.ReadFastArray(reinterpret_cast(fAddress), n); break;} + case 18: {b.ReadFastArray(reinterpret_cast(fAddress), n); break;} case 9: { TVirtualStreamerInfo* si = GetInfoImp(); - TStreamerElement* se = (TStreamerElement*) si->GetElement(fID); - Double_t *xx = (Double_t*) fAddress; + TStreamerElement* se = si->GetElement(fID); + Double_t *xx = reinterpret_cast(fAddress); for (Int_t ii=0;iiGetElement(fID); - Float_t *xx = (Float_t*) fAddress; + TStreamerElement* se = si->GetElement(fID); + Float_t *xx = reinterpret_cast(fAddress); for (Int_t ii=0;iiCreateIterators(alternate, proxy); } - Int_t nbranches = fBranches.GetEntriesFast(); - switch (fSTLtype) { - case ROOT::kSTLset: - case ROOT::kSTLunorderedset: - case ROOT::kSTLunorderedmultiset: - case ROOT::kSTLmultiset: - case ROOT::kSTLmap: - case ROOT::kSTLmultimap: - case ROOT::kSTLunorderedmap: - case ROOT::kSTLunorderedmultimap: - for (Int_t i = 0; i < nbranches; ++i) { - TBranch *branch = (TBranch*) fBranches[i]; - Int_t nb = branch->GetEntry(GetReadEntry(), 1); - if (nb < 0) { - // Give up on i/o failure. - // FIXME: We need an error message here. - break; - } + if (IsAssociativeContainer(*proxy)) { + + Int_t nbranches = fBranches.GetEntriesFast(); + for (Int_t i = 0; i < nbranches; ++i) { + TBranch *branch = static_cast(fBranches[i]); + // To ensure that the sub-branches are read, we need + // reset their entry cursor. + RecursiveResetReadEntry(branch); + Int_t nb = branch->GetEntry(GetReadEntry(), 1); + if (nb < 0) { + // Give up on i/o failure. + // FIXME: We need an error message here. + break; } - break; - default: - break; + } } //------------------------------------------------------------------------ // We have split this stuff, so we need to create the pointers @@ -4366,12 +4391,12 @@ void TBranchElement::ReadLeavesCollection(TBuffer& b) Int_t i = 0; // coverity[returned_null] the fNdata is check enough to prevent the use of null value of At(0) - if( !fNdata || *(void**)proxy->At( 0 ) != nullptr ) + if( !fNdata || *reinterpret_cast(proxy->At( 0 )) != nullptr ) i = fNdata; for( ; i < fNdata; ++i ) { - void **el = (void**)proxy->At( i ); + void **el = reinterpret_cast(proxy->At( i )); // coverity[dereference] since this is a member streaming action by definition the collection contains objects and elClass is not null. *el = elClass->New(); } @@ -4504,7 +4529,7 @@ void TBranchElement::ReadLeavesClones(TBuffer& b) } } fNdata = n; - TClonesArray* clones = (TClonesArray*) fObject; + TClonesArray* clones = reinterpret_cast(fObject); if (clones->IsZombie()) { return; } @@ -4533,7 +4558,7 @@ void TBranchElement::ReadLeavesClonesMember(TBuffer& b) // TClonesArray sub-branch (contains the elements). fNdata = fBranchCount->GetNdata(); - TClonesArray* clones = (TClonesArray*) fObject; + TClonesArray* clones = reinterpret_cast(fObject); if (clones->IsZombie()) { return; } @@ -4545,7 +4570,7 @@ void TBranchElement::ReadLeavesClonesMember(TBuffer& b) // based on the value of fOnfileObject rather than pushing in on a stack. R__PushCache onfileObject(b, fOnfileObject, fNdata); - char **arr = (char **)clones->GetObjectRef(); + char **arr = reinterpret_cast(clones->GetObjectRef()); char **end = arr + fNdata; b.ApplySequenceVecPtr(*fReadActionSequence,arr,end); } @@ -4574,7 +4599,7 @@ void TBranchElement::ReadLeavesMember(TBuffer& b) // then register with the buffer so that pointers are // handled properly. if (TestBit(kBranchObject)) { - b.MapObject((TObject*) fObject); + b.MapObject(reinterpret_cast(fObject)); } else if (TestBit(kBranchAny)) { b.MapObject(fObject, fBranchClass); } @@ -4610,7 +4635,7 @@ void TBranchElement::ReadLeavesMemberBranchCount(TBuffer& b) // then register with the buffer so that pointers are // handled properly. if (TestBit(kBranchObject)) { - b.MapObject((TObject*) fObject); + b.MapObject(reinterpret_cast(fObject)); } else if (TestBit(kBranchAny)) { b.MapObject(fObject, fBranchClass); } @@ -4646,7 +4671,7 @@ void TBranchElement::ReadLeavesMemberCounter(TBuffer& b) // then register with the buffer so that pointers are // handled properly. if (TestBit(kBranchObject)) { - b.MapObject((TObject*) fObject); + b.MapObject(reinterpret_cast(fObject)); } else if (TestBit(kBranchAny)) { b.MapObject(fObject, fBranchClass); } @@ -4695,8 +4720,8 @@ void TBranchElement::FillLeavesImpl(TBuffer&) void TBranchElement::ReleaseObject() { if (fObject && TestBit(kDeleteObject)) { - if (IsAutoDelete() && fAddress != (char*)&fObject) { - *((char**) fAddress) = nullptr; + if (IsAutoDelete() && fAddress != reinterpret_cast(&fObject)) { + *(reinterpret_cast(fAddress)) = nullptr; } ResetBit(kDeleteObject); if (fType == 3) { @@ -4707,7 +4732,7 @@ void TBranchElement::ReleaseObject() (fStreamerType == TVirtualStreamerInfo::kObjectP)) { // -- We are a pointer to a TClonesArray. // We must zero the pointer in the object. - *((char**) fAddress) = nullptr; + *(reinterpret_cast(fAddress)) = nullptr; } } else if (fType == 4) { // -- We are an STL container master branch. @@ -4720,7 +4745,7 @@ void TBranchElement::ReleaseObject() bool needDelete = proxy->GetProperties()&TVirtualCollectionProxy::kNeedDelete; if (needDelete && fID >= 0) { TVirtualStreamerInfo* si = GetInfoImp(); - TStreamerElement* se = (TStreamerElement*) si->GetElement(fID); + TStreamerElement* se = si->GetElement(fID); needDelete = !se->TestBit(TStreamerElement::kDoNotDelete); } if (needDelete) { @@ -4733,7 +4758,7 @@ void TBranchElement::ReleaseObject() if (fStreamerType == TVirtualStreamerInfo::kSTLp) { // -- We are a pointer to an STL container. // We must zero the pointer in the object. - *((char**) fAddress) = nullptr; + *(reinterpret_cast(fAddress)) = nullptr; } } else { // We are *not* a TClonesArray master branch and we are *not* an STL container master branch. @@ -4776,7 +4801,7 @@ void TBranchElement::Reset(Option_t* option) { Int_t nbranches = fBranches.GetEntriesFast(); for (Int_t i = 0; i < nbranches; ++i) { - TBranch* branch = (TBranch*) fBranches[i]; + TBranch* branch = static_cast(fBranches[i]); branch->Reset(option); } fBranchID = -1; @@ -4791,7 +4816,7 @@ void TBranchElement::ResetAfterMerge(TFileMergeInfo *info) { Int_t nbranches = fBranches.GetEntriesFast(); for (Int_t i = 0; i < nbranches; ++i) { - TBranch* branch = (TBranch*) fBranches[i]; + TBranch* branch = static_cast(fBranches[i]); branch->ResetAfterMerge(info); } TBranch::ResetAfterMerge(info); @@ -4803,7 +4828,7 @@ void TBranchElement::ResetAfterMerge(TFileMergeInfo *info) void TBranchElement::ResetAddress() { for (Int_t i = 0; i < fNleaves; ++i) { - TLeaf* leaf = (TLeaf*) fLeaves.UncheckedAt(i); + TLeaf* leaf = static_cast(fLeaves.UncheckedAt(i)); //if (leaf) leaf->SetAddress(0); leaf->SetAddress(nullptr); } @@ -4813,7 +4838,7 @@ void TBranchElement::ResetAddress() // before giving them a chance to cleanup. Int_t nbranches = fBranches.GetEntriesFast(); for (Int_t i = 0; i < nbranches; ++i) { - TBranch* br = (TBranch*) fBranches[i]; + TBranch* br = static_cast(fBranches[i]); if (br) br->ResetAddress(); } @@ -4839,9 +4864,9 @@ void TBranchElement::ResetDeleteObject() ResetBit(kDeleteObject); Int_t nb = fBranches.GetEntriesFast(); for (Int_t i = 0; i < nb; ++i) { - TBranch* br = (TBranch*) fBranches[i]; + TBranch* br = static_cast(fBranches[i]); if (br->InheritsFrom(TBranchElement::Class())) { - ((TBranchElement*) br)->ResetDeleteObject(); + static_cast(br)->ResetDeleteObject(); } } } @@ -4865,7 +4890,7 @@ void TBranchElement::ResetInitInfo(bool recurse) if (recurse) { Int_t nbranches = fBranches.GetEntriesFast(); for (Int_t i = 0; i < nbranches; ++i) { - TBranchElement *sub = (TBranchElement*) fBranches[i]; + TBranchElement *sub = static_cast(fBranches[i]); sub->ResetInitInfo(true); } } @@ -4926,7 +4951,7 @@ void TBranchElement::ResetInitInfo(bool recurse) /// and owned by us: /// ~~~ {.cpp} /// TFile* f1 = new TFile("myfile_original.root"); -/// TTree* t1 = (TTree*) f->Get("MyTree"); +/// TTree* t1 = f1->Get("MyTree"); /// TFile* f2 = new TFile("myfile_copy.root", "recreate"); /// TTree* t2 = t1->Clone(0); /// for (Int_t i = 0; i < 10; ++i) { @@ -5018,8 +5043,8 @@ void TBranchElement::SetAddressImpl(void* addr, bool implied, Int_t offset) if (Longptr_t(addr) == -1) { // FIXME: Do we have to release an object here? // ReleaseObject(); - fAddress = (char*) -1; - fObject = (char*) -1; + fAddress = reinterpret_cast(-1); + fObject = reinterpret_cast(-1); ResetBit(kDeleteObject); ResetBit(kAddressSet); return; @@ -5059,8 +5084,8 @@ void TBranchElement::SetAddressImpl(void* addr, bool implied, Int_t offset) // Remember the pointer to the pointer to our object. // - fAddress = (char*) addr; - if (fAddress != (char*)(&fObject)) { + fAddress = reinterpret_cast(addr); + if (fAddress != reinterpret_cast(&fObject)) { fObject = nullptr; } ResetBit(kDeleteObject); @@ -5130,7 +5155,7 @@ void TBranchElement::SetAddressImpl(void* addr, bool implied, Int_t offset) if(fSTLtype != ROOT::kSTLvector && fCollProxy->HasPointers() && fSplitLevel > TTree::kSplitCollectionOfPointers ) { fPtrIterators = new TVirtualCollectionPtrIterators(fCollProxy); - } else if (fCollProxy->GetProperties() & TVirtualCollectionProxy::kIsAssociative) { + } else if (IsAssociativeContainer(*fCollProxy)) { fWriteIterators = new TVirtualCollectionIterators(fCollProxy,false); fIterators = new TVirtualCollectionIterators(fCollProxy); } else { @@ -5155,7 +5180,7 @@ void TBranchElement::SetAddressImpl(void* addr, bool implied, Int_t offset) fCollProxy = newType->GetCollectionProxy()->Generate(); fSTLtype = fCollProxy->GetCollectionType(); for (Int_t i = 0; i < nbranches; ++i) { - TBranchElement* br = (TBranchElement*) GetListOfBranches()->UncheckedAt(i); + TBranchElement* br = static_cast(GetListOfBranches()->UncheckedAt(i)); br->fCollProxy = nullptr; if (br->fReadActionSequence) { br->SetReadActionSequence(); @@ -5172,7 +5197,7 @@ void TBranchElement::SetAddressImpl(void* addr, bool implied, Int_t offset) delete fPtrIterators; if(fSTLtype != ROOT::kSTLvector && fCollProxy->HasPointers() && fSplitLevel > TTree::kSplitCollectionOfPointers ) { fPtrIterators = new TVirtualCollectionPtrIterators(fCollProxy); - } else if (fCollProxy->GetProperties() & TVirtualCollectionProxy::kIsAssociative) { + } else if (IsAssociativeContainer(*fCollProxy)) { fWriteIterators = new TVirtualCollectionIterators(fCollProxy,false); fIterators = new TVirtualCollectionIterators(fCollProxy); } else { @@ -5188,7 +5213,7 @@ void TBranchElement::SetAddressImpl(void* addr, bool implied, Int_t offset) fCollProxy = newType->GetCollectionProxy()->Generate(); fSTLtype = fCollProxy->GetCollectionType(); for (Int_t i = 0; i < nbranches; ++i) { - TBranchElement* br = (TBranchElement*) GetListOfBranches()->UncheckedAt(i); + TBranchElement* br = static_cast(GetListOfBranches()->UncheckedAt(i)); br->fCollProxy = nullptr; if (br->fBranchClass == oldValueClass) { br->SetTargetClass(fCollProxy->GetValueClass()->GetName()); @@ -5208,7 +5233,7 @@ void TBranchElement::SetAddressImpl(void* addr, bool implied, Int_t offset) delete fPtrIterators; if(fSTLtype != ROOT::kSTLvector && fCollProxy->HasPointers() && fSplitLevel > TTree::kSplitCollectionOfPointers ) { fPtrIterators = new TVirtualCollectionPtrIterators(fCollProxy); - } else if (fCollProxy->GetProperties() & TVirtualCollectionProxy::kIsAssociative) { + } else if (IsAssociativeContainer(*fCollProxy)) { fWriteIterators = new TVirtualCollectionIterators(fCollProxy,false); fIterators = new TVirtualCollectionIterators(fCollProxy); } else { @@ -5278,7 +5303,7 @@ void TBranchElement::SetAddressImpl(void* addr, bool implied, Int_t offset) if (!fIterators && !fPtrIterators) { if(fSTLtype != ROOT::kSTLvector && GetCollectionProxy()->HasPointers() && fSplitLevel > TTree::kSplitCollectionOfPointers ) { fPtrIterators = new TVirtualCollectionPtrIterators(GetCollectionProxy()); - } else if (fCollProxy->GetProperties() & TVirtualCollectionProxy::kIsAssociative) { + } else if (IsAssociativeContainer(*fCollProxy)) { fWriteIterators = new TVirtualCollectionIterators(fCollProxy,false); fIterators = new TVirtualCollectionIterators(fCollProxy); } else { @@ -5314,7 +5339,7 @@ void TBranchElement::SetAddressImpl(void* addr, bool implied, Int_t offset) // Case of an embedded TClonesArray. fObject = fAddress; // Check if it has already been properly built. - TClonesArray* clones = (TClonesArray*) fObject; + TClonesArray* clones = reinterpret_cast(fObject); if (!clones->GetClass()) { new(fObject) TClonesArray(fClonesClass); } @@ -5327,22 +5352,22 @@ void TBranchElement::SetAddressImpl(void* addr, bool implied, Int_t offset) Error("SetAddress", "TClonesArray with fStreamerType: %d", fStreamerType); } else if (fStreamerType == -1) { // -- We are a top-level branch. - TClonesArray** pp = (TClonesArray**) fAddress; + TClonesArray** pp = reinterpret_cast(fAddress); if (!*pp) { // -- Caller wants us to allocate the clones array, but they will own it. *pp = new TClonesArray(fClonesClass); } - fObject = (char*) *pp; + fObject = reinterpret_cast(*pp); } else { // -- We are a pointer to a TClonesArray. // Note: We do this so that the default constructor, // or the i/o constructor can be lazy. - TClonesArray** pp = (TClonesArray**) fAddress; + TClonesArray** pp = reinterpret_cast(fAddress); if (!*pp) { // -- Caller wants us to allocate the clones array, but they will own it. *pp = new TClonesArray(fClonesClass); } - fObject = (char*) *pp; + fObject = reinterpret_cast(*pp); } } } else { @@ -5362,8 +5387,8 @@ void TBranchElement::SetAddressImpl(void* addr, bool implied, Int_t offset) // -- We are a top-level branch. // Idea: Consider making a zero address not allocate. SetBit(kDeleteObject); - fObject = (char*) new TClonesArray(fClonesClass); - fAddress = (char*) &fObject; + fObject = reinterpret_cast(new TClonesArray(fClonesClass)); + fAddress = reinterpret_cast(&fObject); } else { // -- We are a sub-branch which is a pointer to a TClonesArray. Error("SetAddress", "Embedded pointer to a TClonesArray given a zero address for branch '%s'", GetName()); @@ -5394,7 +5419,7 @@ void TBranchElement::SetAddressImpl(void* addr, bool implied, Int_t offset) GetName(), fStreamerType); } else if (fStreamerType == -1) { // -- We are a top-level branch. - void** pp = (void**) fAddress; + void** pp = reinterpret_cast(fAddress); if (!*pp) { // -- Caller wants us to allocate the STL container, but they will own it. *pp = proxy->New(); @@ -5407,12 +5432,12 @@ void TBranchElement::SetAddressImpl(void* addr, bool implied, Int_t offset) ResetBit(kAddressSet); } } - fObject = (char*) *pp; + fObject = reinterpret_cast(*pp); } else { // -- We are a pointer to an STL container. // Note: We do this so that the default constructor, // or the i/o constructor can be lazy. - void** pp = (void**) fAddress; + void** pp = reinterpret_cast(fAddress); if (!*pp) { // -- Caller wants us to allocate the STL container, but they will own it. *pp = proxy->New(); @@ -5425,7 +5450,7 @@ void TBranchElement::SetAddressImpl(void* addr, bool implied, Int_t offset) ResetBit(kAddressSet); } } - fObject = (char*) *pp; + fObject = reinterpret_cast(*pp); } } } else { @@ -5448,9 +5473,9 @@ void TBranchElement::SetAddressImpl(void* addr, bool implied, Int_t offset) } else if (fStreamerType == -1) { // -- We are a top-level branch, allocate. SetBit(kDeleteObject); - fObject = (char*) proxy->New(); + fObject = reinterpret_cast(proxy->New()); if (fObject) { - fAddress = (char*) &fObject; + fAddress = reinterpret_cast(&fObject); } else { Error("SetAddress", "Failed to allocate STL container for branch '%s'", GetName()); // FIXME: Should we do this? Lots of other code wants @@ -5473,7 +5498,7 @@ void TBranchElement::SetAddressImpl(void* addr, bool implied, Int_t offset) fObject = fAddress; } else if (fID < 0) { // -- We are a top-level branch. - char** pp = (char**) fAddress; + char** pp = reinterpret_cast(fAddress); if (pp && *pp) { // -- Caller provided an i/o buffer for us to use. fObject = *pp; @@ -5484,11 +5509,11 @@ void TBranchElement::SetAddressImpl(void* addr, bool implied, Int_t offset) // -- Caller wants us to own the object. SetBit(kDeleteObject); } - fObject = (char*) clOfBranch->New(); + fObject = reinterpret_cast(clOfBranch->New()); if (pp) { *pp = fObject; } else { - fAddress = (char*) &fObject; + fAddress = reinterpret_cast(&fObject); } } else { Error("SetAddress", "I have no TClass for branch %s, so I cannot allocate an I/O buffer!", GetName()); @@ -5523,7 +5548,7 @@ void TBranchElement::SetAddressImpl(void* addr, bool implied, Int_t offset) localObject = fOnfileObject->GetObjectAt(0) + offset; } for (Int_t i = 0; i < nbranches; ++i) { - TBranch *abranch = (TBranch*) fBranches.UncheckedAt(i); + TBranch *abranch = static_cast(fBranches.UncheckedAt(i)); // FIXME: This is a tail recursion! if (fBranchOffset[i] != TStreamerInfo::kMissing && !(implied && abranch->TestBit(kAddressSet))) { abranch->SetAddressImpl(localObject + fBranchOffset[i], implied, fBranchOffset[i]); @@ -5543,12 +5568,12 @@ void TBranchElement::SetAddressImpl(void* addr, bool implied, Int_t offset) //////////////////////////////////////////////////////////////////////////////// /// Reset the basket size for all sub-branches of this branch element. -void TBranchElement::SetBasketSize(Int_t buffsize) +void TBranchElement::SetBasketSize(Int_t bufsize) { - TBranch::SetBasketSize(buffsize); + TBranch::SetBasketSize(bufsize); Int_t nbranches = fBranches.GetEntriesFast(); for (Int_t i = 0; i < nbranches; ++i) { - TBranch* branch = (TBranch*) fBranches[i]; + TBranch* branch = static_cast(fBranches[i]); branch->SetBasketSize(fBasketSize); } } @@ -5561,8 +5586,8 @@ void TBranchElement::SetBranchCount(TBranchElement* brOfCounter) fBranchCount = brOfCounter; if (fBranchCount==nullptr) return; - TLeafElement* leafOfCounter = (TLeafElement*) brOfCounter->GetListOfLeaves()->At(0); - TLeafElement* leaf = (TLeafElement*) GetListOfLeaves()->At(0); + TLeafElement* leafOfCounter = static_cast(brOfCounter->GetListOfLeaves()->At(0)); + TLeafElement* leaf = static_cast(GetListOfLeaves()->At(0)); if (leafOfCounter && leaf) { leaf->SetLeafCount(leafOfCounter); } else { @@ -5590,7 +5615,7 @@ bool TBranchElement::SetMakeClass(bool decomposeObj) Int_t nbranches = fBranches.GetEntriesFast(); for (Int_t i = 0; i < nbranches; ++i) { - TBranchElement* branch = (TBranchElement*) fBranches[i]; + TBranchElement* branch = static_cast(fBranches[i]); branch->SetMakeClass(decomposeObj); } SetReadLeavesPtr(); @@ -5607,7 +5632,7 @@ void TBranchElement::SetObject(void* obj) if (TestBit(kDoNotProcess)) { return; } - fObject = (char*)obj; + fObject = reinterpret_cast(obj); SetAddress( &fObject ); } @@ -5851,7 +5876,7 @@ void TBranchElement::SetFillLeavesPtr() } else { fFillLeaves = (FillLeaves_t)&TBranchElement::FillLeavesCollectionSplitPtrMember; } - } else if (GetCollectionProxy()->GetProperties() & TVirtualCollectionProxy::kIsAssociative) { + } else if (IsAssociativeContainer(*GetCollectionProxy())) { fFillLeaves = (FillLeaves_t)&TBranchElement::FillLeavesAssociativeCollectionMember; } else { fFillLeaves = (FillLeaves_t)&TBranchElement::FillLeavesCollectionMember; @@ -5895,7 +5920,7 @@ void TBranchElement::SetTargetClass(const char *name) Int_t nbranches = fBranches.GetEntriesFast(); for (Int_t i = 0; i < nbranches; ++i) { - TBranchElement *sub = (TBranchElement*) fBranches[i]; + TBranchElement *sub = static_cast(fBranches[i]); if (sub->fTargetClass == fTargetClass ) { sub->SetTargetClass(name); @@ -5951,7 +5976,7 @@ void TBranchElement::SetupAddressesImpl() if( fType == 41 && fSplitLevel >= TTree::kSplitCollectionOfPointers ) { - TBranchElement *parent = (TBranchElement *)GetMother()->GetSubBranch( this ); + TBranchElement *parent = static_cast(GetMother()->GetSubBranch( this )); // Make sure the StreamerInfo is loaded and initialized. GetInfoImp(); @@ -5965,7 +5990,7 @@ void TBranchElement::SetupAddressesImpl() // Any other case ///////////////////////////////////////////////////////////////////////////// - TBranchElement* mother = (TBranchElement*) GetMother(); + TBranchElement* mother = static_cast(GetMother()); if (!mother) { return; } @@ -6114,7 +6139,7 @@ void TBranchElement::Unroll(const char *name, TClass *cl, TStreamerInfo *sinfo, // Note: The branch constructor which takes a folder as input // creates top-level branch names with dots in them to // indicate the folder hierarchy. - char* dot = (char*) strchr(name, '.'); + const char* dot = strchr(name, '.'); Int_t nch = strlen(name); bool dotlast = false; if (nch && (name[nch-1] == '.')) { @@ -6126,7 +6151,7 @@ void TBranchElement::Unroll(const char *name, TClass *cl, TStreamerInfo *sinfo, TIter next(sinfo->GetElements()); TStreamerElement* element = nullptr; TString bname; - for (Int_t id = 0; (element = (TStreamerElement*) next()); ++id) { + for (Int_t id = 0; (element = static_cast(next())); ++id) { if (element->IsA() == TStreamerArtificial::Class()) { continue; } @@ -6136,7 +6161,7 @@ void TBranchElement::Unroll(const char *name, TClass *cl, TStreamerInfo *sinfo, if (element->TestBit(TStreamerElement::kCache) && !element->TestBit(TStreamerElement::kWrite)) { continue; } - char* pointer = (char*) (objptr + element->GetOffset()); + char* pointer = (objptr + element->GetOffset()); // FIXME: This is not good enough, an STL container can be // a base, and the test will fail. // See TBranchElement::InitializeOffsets() for the diff --git a/tree/tree/src/TBranchObject.cxx b/tree/tree/src/TBranchObject.cxx index 026514ad74ef0..9b6f9b9185009 100644 --- a/tree/tree/src/TBranchObject.cxx +++ b/tree/tree/src/TBranchObject.cxx @@ -528,9 +528,9 @@ void TBranchObject::SetAutoDelete(bool autodel) //////////////////////////////////////////////////////////////////////////////// /// Reset basket size for all subbranches of this branch. -void TBranchObject::SetBasketSize(Int_t buffsize) +void TBranchObject::SetBasketSize(Int_t bufsize) { - TBranch::SetBasketSize(buffsize); + TBranch::SetBasketSize(bufsize); Int_t nbranches = fBranches.GetEntriesFast(); for (Int_t i = 0; i < nbranches; ++i) { diff --git a/tree/tree/src/TBranchSTL.cxx b/tree/tree/src/TBranchSTL.cxx index 9dd82119b86c0..65887ae835d04 100644 --- a/tree/tree/src/TBranchSTL.cxx +++ b/tree/tree/src/TBranchSTL.cxx @@ -45,13 +45,13 @@ TBranchSTL::TBranchSTL(): //////////////////////////////////////////////////////////////////////////////// /// Normal constructor, called from TTree. -TBranchSTL::TBranchSTL( TTree *tree, const char *name, - TVirtualCollectionProxy *collProxy, - Int_t buffsize, Int_t splitlevel ) +TBranchSTL::TBranchSTL(TTree *tree, const char *name, + TVirtualCollectionProxy *collProxy, + Int_t bufsize, Int_t splitlevel ) { fTree = tree; fCollProxy = collProxy; - fBasketSize = buffsize; + fBasketSize = bufsize; fSplitLevel = splitlevel; fContName = collProxy->GetCollectionClass()->GetName(); fClCheckSum = 0; @@ -87,14 +87,14 @@ TBranchSTL::TBranchSTL( TTree *tree, const char *name, //////////////////////////////////////////////////////////////////////////////// /// Normal constructor, called from another branch. -TBranchSTL::TBranchSTL( TBranch* parent, const char* name, - TVirtualCollectionProxy* collProxy, - Int_t buffsize, Int_t splitlevel, - TStreamerInfo* info, Int_t id ) +TBranchSTL::TBranchSTL(TBranch* parent, const char* name, + TVirtualCollectionProxy* collProxy, + Int_t bufsize, Int_t splitlevel, + TStreamerInfo* info, Int_t id ) { fTree = parent->GetTree(); fCollProxy = collProxy; - fBasketSize = buffsize; + fBasketSize = bufsize; fSplitLevel = splitlevel; fContName = collProxy->GetCollectionClass()->GetName(); fClassName = info->GetClass()->GetName(); diff --git a/tree/tree/src/TBufferSQL.cxx b/tree/tree/src/TBufferSQL.cxx index 4d04c7da88b24..6933bc9d2890f 100644 --- a/tree/tree/src/TBufferSQL.cxx +++ b/tree/tree/src/TBufferSQL.cxx @@ -41,9 +41,9 @@ TBufferSQL::TBufferSQL(TBuffer::EMode mode, std::vector *vc, //////////////////////////////////////////////////////////////////////////////// /// Constructor. -TBufferSQL::TBufferSQL(TBuffer::EMode mode, Int_t bufsiz, std::vector *vc, +TBufferSQL::TBufferSQL(TBuffer::EMode mode, Int_t bufsize, std::vector *vc, TString *insert_query, TSQLRow ** r) : - TBufferFile(mode,bufsiz), + TBufferFile(mode,bufsize), fColumnVec(vc), fInsertQuery(insert_query), fRowPtr(r) { fIter = fColumnVec->begin(); @@ -52,10 +52,10 @@ TBufferSQL::TBufferSQL(TBuffer::EMode mode, Int_t bufsiz, std::vector *vc //////////////////////////////////////////////////////////////////////////////// /// Constructor. -TBufferSQL::TBufferSQL(TBuffer::EMode mode, Int_t bufsiz, std::vector *vc, +TBufferSQL::TBufferSQL(TBuffer::EMode mode, Int_t bufsize, std::vector *vc, TString *insert_query, TSQLRow ** r, void *buf, bool adopt) : - TBufferFile(mode,bufsiz,buf,adopt), + TBufferFile(mode,bufsize,buf,adopt), fColumnVec(vc), fInsertQuery(insert_query), fRowPtr(r) { fIter = fColumnVec->begin(); diff --git a/tree/tree/src/TTree.cxx b/tree/tree/src/TTree.cxx index 7ccd17df59584..263c10ba072bc 100644 --- a/tree/tree/src/TTree.cxx +++ b/tree/tree/src/TTree.cxx @@ -139,7 +139,7 @@ It is strongly recommended to persistify those as objects rather than lists of l ## Adding a column holding STL collection instances (e.g. std::vector or std::list) ~~~ {.cpp} - auto branch = tree.Branch( branchname, STLcollection, buffsize, splitlevel); + auto branch = tree.Branch( branchname, STLcollection, bufsize, splitlevel); ~~~ `STLcollection` is the address of a pointer to a container of the standard library such as `std::vector`, `std::list`, containing pointers, fundamental types @@ -8455,9 +8455,9 @@ void TTree::SetAutoSave(Long64_t autos) /// - if bname="xxx*", apply to all branches with name starting with xxx /// /// see TRegexp for wildcarding options -/// buffsize = branc basket size +/// bufsize = branch basket size -void TTree::SetBasketSize(const char* bname, Int_t buffsize) +void TTree::SetBasketSize(const char* bname, Int_t bufsize) { Int_t nleaves = fLeaves.GetEntriesFast(); TRegexp re(bname, true); @@ -8470,7 +8470,7 @@ void TTree::SetBasketSize(const char* bname, Int_t buffsize) continue; } nb++; - branch->SetBasketSize(buffsize); + branch->SetBasketSize(bufsize); } if (!nb) { Error("SetBasketSize", "unknown branch -> '%s'", bname); diff --git a/tree/tree/src/TTreeCache.cxx b/tree/tree/src/TTreeCache.cxx index 205b8e496c1a2..ae2490383a38a 100644 --- a/tree/tree/src/TTreeCache.cxx +++ b/tree/tree/src/TTreeCache.cxx @@ -317,8 +317,8 @@ TTreeCache::TTreeCache() : TFileCacheRead(), fPrefillType(GetConfiguredPrefillTy //////////////////////////////////////////////////////////////////////////////// /// Constructor. -TTreeCache::TTreeCache(TTree *tree, Int_t buffersize) - : TFileCacheRead(tree->GetCurrentFile(), buffersize, tree), fEntryMax(tree->GetEntriesFast()), fEntryNext(0), +TTreeCache::TTreeCache(TTree *tree, Int_t bufsize) + : TFileCacheRead(tree->GetCurrentFile(), bufsize, tree), fEntryMax(tree->GetEntriesFast()), fEntryNext(0), fBrNames(new TList), fTree(tree), fPrefillType(GetConfiguredPrefillType()) { fEntryNext = fEntryMin + fgLearnEntries; diff --git a/tree/tree/src/TTreeCacheUnzip.cxx b/tree/tree/src/TTreeCacheUnzip.cxx index d5ccf78604668..5d338e32b5198 100644 --- a/tree/tree/src/TTreeCacheUnzip.cxx +++ b/tree/tree/src/TTreeCacheUnzip.cxx @@ -175,7 +175,7 @@ TTreeCacheUnzip::TTreeCacheUnzip() : TTreeCache(), //////////////////////////////////////////////////////////////////////////////// /// Constructor. -TTreeCacheUnzip::TTreeCacheUnzip(TTree *tree, Int_t buffersize) : TTreeCache(tree,buffersize), +TTreeCacheUnzip::TTreeCacheUnzip(TTree *tree, Int_t bufsize) : TTreeCache(tree,bufsize), fAsyncReading(false), fEmpty(true), fCycle(0),