From 0f8918577415e57503f253f2394e8e1755458b36 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Mon, 9 Dec 2024 14:53:02 +0100 Subject: [PATCH] strlen optimization: use constexpr instead of runtime-constant strlen cannot be a constexpr in all platforms otherwise. --- core/base/src/TUrl.cxx | 2 +- core/foundation/src/TClassEdit.cxx | 63 ++++++++++--------- core/meta/src/TClass.cxx | 2 +- core/metacling/src/TCling.cxx | 2 +- graf3d/gl/src/gl2ps.cxx | 7 ++- hist/hist/src/HFitImpl.cxx | 5 +- .../lib/Interpreter/ForwardDeclPrinter.cpp | 2 +- io/io/src/TFile.cxx | 4 +- io/io/src/TMakeProject.cxx | 2 +- io/io/src/TStreamerInfo.cxx | 8 +-- io/sql/src/TSQLObjectData.cxx | 2 +- main/src/h2root.cxx | 2 +- main/src/hadd.cxx | 2 +- tree/tree/src/TBranch.cxx | 2 +- tree/tree/src/TBranchElement.cxx | 9 +-- tree/tree/src/TBranchSTL.cxx | 7 ++- tree/tree/src/TTree.cxx | 2 +- tree/treeplayer/src/TFormLeafInfo.cxx | 2 +- tree/treeplayer/src/TTreePlayer.cxx | 29 ++++----- 19 files changed, 82 insertions(+), 72 deletions(-) diff --git a/core/base/src/TUrl.cxx b/core/base/src/TUrl.cxx index 91821d381e016..d06c72c1b4ce2 100644 --- a/core/base/src/TUrl.cxx +++ b/core/base/src/TUrl.cxx @@ -195,7 +195,7 @@ void TUrl::SetUrl(const char *url, Bool_t defaultIsFile) // allow url of form: "proto://" } else { if (defaultIsFile) { - const std::size_t bufferSize = strlen("file:") + strlen(u0) + 1; + const std::size_t bufferSize = std::char_traits::length("file:") + strlen(u0) + 1; char *newu = new char [bufferSize]; snprintf(newu, bufferSize, "file:%s", u0); delete [] u0; diff --git a/core/foundation/src/TClassEdit.cxx b/core/foundation/src/TClassEdit.cxx index bbba888b3c78d..5d7a8872ab7ff 100644 --- a/core/foundation/src/TClassEdit.cxx +++ b/core/foundation/src/TClassEdit.cxx @@ -624,7 +624,8 @@ bool TClassEdit::IsDefAlloc(const char *allocname, const char *classname) string_view a( allocname ); // In Windows, allocname might be 'class const std::allocator', // (never 'const class ...'), so we start by stripping the 'class ', if any - constexpr static int clalloclen = std::char_traits::length("class "); + constexpr auto length = std::char_traits::length; + constexpr static int clalloclen = length("class "); if (a.compare(0,clalloclen,"class ") == 0) { a.remove_prefix(clalloclen); } @@ -634,7 +635,7 @@ bool TClassEdit::IsDefAlloc(const char *allocname, const char *classname) if (a=="__default_alloc_template") return true; if (a=="__malloc_alloc_template<0>") return true; - constexpr static int alloclen = std::char_traits::length("allocator<"); + constexpr static int alloclen = length("allocator<"); if (a.compare(0,alloclen,"allocator<") != 0) { return false; } @@ -683,7 +684,8 @@ bool TClassEdit::IsDefAlloc(const char *allocname, string_view a( allocname ); RemoveStd(a); - constexpr static int alloclen = std::char_traits::length("allocator<"); + constexpr auto length = std::char_traits::length; + constexpr static int alloclen = length("allocator<"); if (a.compare(0,alloclen,"allocator<") != 0) { return false; } @@ -691,7 +693,7 @@ bool TClassEdit::IsDefAlloc(const char *allocname, RemoveStd(a); - constexpr static int pairlen = std::char_traits::length("pair<"); + constexpr static int pairlen = length("pair<"); if (a.compare(0,pairlen,"pair<") != 0) { return false; } @@ -1082,8 +1084,10 @@ int TClassEdit::GetSplit(const char *type, vector& output, int &nestedLo if (full.compare(offset, 5, "std::") == 0) { offset += 5; } - static const char* char_traits_s = "char_traits"; - static const unsigned int char_traits_len = strlen(char_traits_s); + constexpr auto char_traits_s = "char_traits"; + // or + // static constexpr char const* const char_traits_s = "char_traits"; + static constexpr unsigned int char_traits_len = std::char_traits::length(char_traits_s); if (full.compare(offset, char_traits_len, char_traits_s) == 0) { offset += char_traits_len; if ( full[offset] == '>') { @@ -1347,7 +1351,7 @@ bool TClassEdit::IsInterpreterDetail(const char *type) bool TClassEdit::IsSTLBitset(const char *classname) { size_t offset = StdLen(classname); - if ( strncmp(classname+offset,"bitset<",strlen("bitset<"))==0) return true; + if ( strncmp(classname+offset,"bitset<",std::char_traits::length("bitset<"))==0) return true; return false; } @@ -1424,32 +1428,33 @@ int TClassEdit::IsSTLCont(const char *type, int testAlloc) bool TClassEdit::IsStdClass(const char *classname) { + constexpr auto length = std::char_traits::length; classname += StdLen( classname ); if ( strcmp(classname,"string")==0 ) return true; - if ( strncmp(classname,"bitset<",strlen("bitset<"))==0) return true; + if ( strncmp(classname,"bitset<",length("bitset<"))==0) return true; if ( IsStdPair(classname) ) return true; if ( strcmp(classname,"allocator")==0) return true; - if ( strncmp(classname,"allocator<",strlen("allocator<"))==0) return true; - if ( strncmp(classname,"greater<",strlen("greater<"))==0) return true; - if ( strncmp(classname,"less<",strlen("less<"))==0) return true; - if ( strncmp(classname,"equal_to<",strlen("equal_to<"))==0) return true; - if ( strncmp(classname,"hash<",strlen("hash<"))==0) return true; - if ( strncmp(classname,"auto_ptr<",strlen("auto_ptr<"))==0) return true; - - if ( strncmp(classname,"vector<",strlen("vector<"))==0) return true; - if ( strncmp(classname,"list<",strlen("list<"))==0) return true; - if ( strncmp(classname,"forward_list<",strlen("forward_list<"))==0) return true; - if ( strncmp(classname,"deque<",strlen("deque<"))==0) return true; - if ( strncmp(classname,"map<",strlen("map<"))==0) return true; - if ( strncmp(classname,"multimap<",strlen("multimap<"))==0) return true; - if ( strncmp(classname,"set<",strlen("set<"))==0) return true; - if ( strncmp(classname,"multiset<",strlen("multiset<"))==0) return true; - if ( strncmp(classname,"unordered_set<",strlen("unordered_set<"))==0) return true; - if ( strncmp(classname,"unordered_multiset<",strlen("unordered_multiset<"))==0) return true; - if ( strncmp(classname,"unordered_map<",strlen("unordered_map<"))==0) return true; - if ( strncmp(classname,"unordered_multimap<",strlen("unordered_multimap<"))==0) return true; - if ( strncmp(classname,"bitset<",strlen("bitset<"))==0) return true; - if ( strncmp(classname,"ROOT::VecOps::RVec<",strlen("ROOT::VecOps::RVec<"))==0) return true; + if ( strncmp(classname,"allocator<",length("allocator<"))==0) return true; + if ( strncmp(classname,"greater<",length("greater<"))==0) return true; + if ( strncmp(classname,"less<",length("less<"))==0) return true; + if ( strncmp(classname,"equal_to<",length("equal_to<"))==0) return true; + if ( strncmp(classname,"hash<",length("hash<"))==0) return true; + if ( strncmp(classname,"auto_ptr<",length("auto_ptr<"))==0) return true; + + if ( strncmp(classname,"vector<",length("vector<"))==0) return true; + if ( strncmp(classname,"list<",length("list<"))==0) return true; + if ( strncmp(classname,"forward_list<",length("forward_list<"))==0) return true; + if ( strncmp(classname,"deque<",length("deque<"))==0) return true; + if ( strncmp(classname,"map<",length("map<"))==0) return true; + if ( strncmp(classname,"multimap<",length("multimap<"))==0) return true; + if ( strncmp(classname,"set<",length("set<"))==0) return true; + if ( strncmp(classname,"multiset<",length("multiset<"))==0) return true; + if ( strncmp(classname,"unordered_set<",length("unordered_set<"))==0) return true; + if ( strncmp(classname,"unordered_multiset<",length("unordered_multiset<"))==0) return true; + if ( strncmp(classname,"unordered_map<",length("unordered_map<"))==0) return true; + if ( strncmp(classname,"unordered_multimap<",length("unordered_multimap<"))==0) return true; + if ( strncmp(classname,"bitset<",length("bitset<"))==0) return true; + if ( strncmp(classname,"ROOT::VecOps::RVec<",length("ROOT::VecOps::RVec<"))==0) return true; return false; } diff --git a/core/meta/src/TClass.cxx b/core/meta/src/TClass.cxx index 990ccf2842292..80c8af356f5c2 100644 --- a/core/meta/src/TClass.cxx +++ b/core/meta/src/TClass.cxx @@ -3220,7 +3220,7 @@ TClass *TClass::GetClass(const char *name, Bool_t load, Bool_t silent, size_t hi return pairinfo->GetClass(); } else { // Check if we have an STL container that might provide it. - static const size_t slen = strlen("pair"); + static constexpr size_t slen = std::char_traits::length("pair"); static const char *associativeContainer[] = { "map", "unordered_map", "multimap", "unordered_multimap", "set", "unordered_set", "multiset", "unordered_multiset" }; for(auto contname : associativeContainer) { diff --git a/core/metacling/src/TCling.cxx b/core/metacling/src/TCling.cxx index d5cb7b1745f2d..db04d5110daa3 100644 --- a/core/metacling/src/TCling.cxx +++ b/core/metacling/src/TCling.cxx @@ -4096,7 +4096,7 @@ void TCling::SetClassInfo(TClass* cl, Bool_t reload, Bool_t silent) // Handle the special case of 'tuple' where we ignore the real implementation // details and just overlay a 'simpler'/'simplistic' version that is easy // for the I/O to understand and handle. - if (strncmp(cl->GetName(),"tuple<",strlen("tuple<"))==0) { + if (strncmp(cl->GetName(),"tuple<",std::char_traits::length("tuple<"))==0) { if (!reload) name = AlternateTuple(cl->GetName(), fInterpreter->getLookupHelper(), silent); if (reload || name.empty()) { diff --git a/graf3d/gl/src/gl2ps.cxx b/graf3d/gl/src/gl2ps.cxx index 271e12fd0e914..126fd69885675 100644 --- a/graf3d/gl/src/gl2ps.cxx +++ b/graf3d/gl/src/gl2ps.cxx @@ -64,6 +64,7 @@ #include #include #include +#include #if defined(GL2PS_HAVE_ZLIB) #include @@ -4428,10 +4429,10 @@ static int gl2psPrintPDFShaderMask(int obj, int childobj) obj, (int)gl2ps->viewport[0], (int)gl2ps->viewport[1], (int)gl2ps->viewport[2], (int)gl2ps->viewport[3]); - + constexpr auto length = std::char_traits::length; len = (childobj>0) - ? strlen("/TrSh sh\n") + (int)log10((double)childobj)+1 - : strlen("/TrSh0 sh\n"); + ? length("/TrSh sh\n") + (int)log10((double)childobj)+1 + : length("/TrSh0 sh\n"); offs += fprintf(gl2ps->stream, "/Length %d\n" diff --git a/hist/hist/src/HFitImpl.cxx b/hist/hist/src/HFitImpl.cxx index 6f3f2a2e8e8cc..054b866d8e82b 100644 --- a/hist/hist/src/HFitImpl.cxx +++ b/hist/hist/src/HFitImpl.cxx @@ -760,14 +760,15 @@ void ROOT::Fit::FitOptionsMake(EFitObjectType type, const char *option, Foption_ //for robust fitting, see if # of good points is defined // decode parameters for robust fitting Double_t h=0; + constexpr auto length = std::char_traits::length; if (opt.Contains("H=0.")) { int start = opt.Index("H=0."); - int numpos = start + strlen("H=0."); + int numpos = start + length("H=0."); int numlen = 0; int len = opt.Length(); while( (numpos+numlengetASTContext().getLangOpts().Modules && llvm::StringRef(includeText).starts_with("include ")) { - includeText += strlen("include "); + includeText += std::char_traits::length("include "); } assert((includeText[0] == '<' || includeText[0] == '"') && diff --git a/io/io/src/TFile.cxx b/io/io/src/TFile.cxx index 54ed25c2470f4..cee4d1ba2f395 100644 --- a/io/io/src/TFile.cxx +++ b/io/io/src/TFile.cxx @@ -3086,7 +3086,7 @@ void TFile::MakeProject(const char *dirname, const char * /*classes*/, if (info->IsA() != TStreamerInfo::Class()) { continue; } - if (strncmp(info->GetName(), "auto_ptr<", strlen("auto_ptr<")) == 0) { + if (strncmp(info->GetName(), "auto_ptr<", std::char_traits::length("auto_ptr<")) == 0) { continue; } TClass *cl = TClass::GetClass(info->GetName()); @@ -4129,7 +4129,7 @@ TFile *TFile::Open(const char *url, Option_t *options, const char *ftitle, TString opts(options); Int_t ito = opts.Index("TIMEOUT="); if (ito != kNPOS) { - TString sto = opts(ito + strlen("TIMEOUT="), opts.Length()); + TString sto = opts(ito + std::char_traits::length("TIMEOUT="), opts.Length()); while (!(sto.IsDigit()) && !(sto.IsNull())) { sto.Remove(sto.Length()-1,1); } if (!(sto.IsNull())) { // Timeout in millisecs diff --git a/io/io/src/TMakeProject.cxx b/io/io/src/TMakeProject.cxx index 8017e82c63610..6592c03917318 100644 --- a/io/io/src/TMakeProject.cxx +++ b/io/io/src/TMakeProject.cxx @@ -524,7 +524,7 @@ UInt_t TMakeProject::GenerateIncludeForTemplate(FILE *fp, const char *clname, ch } else if (TClassEdit::IsStdPair(incName)) { AddInclude(fp, "utility", kTRUE, inclist); ninc += GenerateIncludeForTemplate(fp, incName, inclist, forward, extrainfos); - } else if (strncmp(incName.Data(), "auto_ptr<", strlen("auto_ptr<")) == 0) { + } else if (strncmp(incName.Data(), "auto_ptr<", std::char_traits::length("auto_ptr<")) == 0) { AddInclude(fp, "memory", kTRUE, inclist); ninc += GenerateIncludeForTemplate(fp, incName, inclist, forward, extrainfos); } else if (TClassEdit::IsStdClass(incName)) { diff --git a/io/io/src/TStreamerInfo.cxx b/io/io/src/TStreamerInfo.cxx index 534ae10f2cc49..de31d5ac7a9ee 100644 --- a/io/io/src/TStreamerInfo.cxx +++ b/io/io/src/TStreamerInfo.cxx @@ -3836,7 +3836,7 @@ void TStreamerInfo::GenerateDeclaration(FILE *fp, FILE *sfp, const TList *subCla // nothing to do. break; } - } else if (strncmp(enamebasic.Data(), "auto_ptr<", strlen("auto_ptr<")) == 0) { + } else if (strncmp(enamebasic.Data(), "auto_ptr<", std::char_traits::length("auto_ptr<")) == 0) { enamebasic = TMakeProject::UpdateAssociativeToVector(enamebasic); } @@ -3986,7 +3986,7 @@ UInt_t TStreamerInfo::GenerateIncludes(FILE *fp, char *inclist, const TList *ext } if (TClassEdit::IsStdPair(element->GetTypeName())) { TMakeProject::AddInclude( fp, "utility", kTRUE, inclist); - } else if (strncmp(element->GetTypeName(),"auto_ptr<",strlen("auto_ptr<"))==0) { + } else if (strncmp(element->GetTypeName(),"auto_ptr<",std::char_traits::length("auto_ptr<"))==0) { TMakeProject::AddInclude( fp, "memory", kTRUE, inclist); } else { TString incName( include, strlen(include)-1 ); @@ -4011,7 +4011,7 @@ Int_t TStreamerInfo::GenerateHeaderFile(const char *dirname, const TList *subCla // if (fClassVersion == -4) return 0; if ((fClass && fClass->GetCollectionType()) || TClassEdit::IsSTLCont(GetName())) return 0; if (TClassEdit::IsStdPair(GetName())) return 0; - if (strncmp(GetName(),"auto_ptr<",strlen("auto_ptr<"))==0) return 0; + if (strncmp(GetName(),"auto_ptr<",std::char_traits::length("auto_ptr<"))==0) return 0; TClass *cl = TClass::GetClass(GetName()); if (cl) { @@ -5838,7 +5838,7 @@ TVirtualStreamerInfo *TStreamerInfo::GenerateInfoForPair(const std::string &firs TVirtualStreamerInfo *TStreamerInfo::GenerateInfoForPair(const std::string &pairclassname, bool silent, size_t hint_pair_offset, size_t hint_pair_size) { - const static int pairlen = strlen("pair<"); + const static int pairlen = std::char_traits::length("pair<"); if (pairclassname.compare(0, pairlen, "pair<") != 0) { if (!silent) Error("GenerateInfoForPair", "The class name passed is not a pair: %s", pairclassname.c_str()); diff --git a/io/sql/src/TSQLObjectData.cxx b/io/sql/src/TSQLObjectData.cxx index cb3f7e7f2ad0a..5c820dda4ecb8 100644 --- a/io/sql/src/TSQLObjectData.cxx +++ b/io/sql/src/TSQLObjectData.cxx @@ -238,7 +238,7 @@ Bool_t TSQLObjectData::ExtractBlobValues() fBlobTypeName = name; } else { fBlobPrefixName = name; - separ += strlen(":"); // SQLNameSeparator() + separ += std::char_traits::length(":"); // SQLNameSeparator() fBlobTypeName = separ; } diff --git a/main/src/h2root.cxx b/main/src/h2root.cxx index b374c16c2ffaf..79a1584404ae2 100644 --- a/main/src/h2root.cxx +++ b/main/src/h2root.cxx @@ -294,7 +294,7 @@ int main(int argc, char **argv) if (argc > 2) { file_out=argv[2]; } else { - Int_t nchf = strlen(file_in)+strlen(".root")+1; + Int_t nchf = strlen(file_in)+std::char_traits::length(".root")+1; file_out= new char[nchf]; strlcpy(file_out,file_in,nchf); char *dot = strrchr(file_out,'.'); diff --git a/main/src/hadd.cxx b/main/src/hadd.cxx index 933859f3941a6..6934df8944bdd 100644 --- a/main/src/hadd.cxx +++ b/main/src/hadd.cxx @@ -211,7 +211,7 @@ int main( int argc, char **argv ) ++ffirst; } else if ( strcmp(argv[a],"-cachesize=") == 0 ) { int size; - static const size_t arglen = strlen("-cachesize="); + static constexpr size_t arglen = std::char_traits::length("-cachesize="); auto parseResult = ROOT::FromHumanReadableSize(argv[a]+arglen,size); if (parseResult == ROOT::EFromHumanReadableSize::kParseFail) { std::cerr << "Error: could not parse the cache size passed after -cachesize: " diff --git a/tree/tree/src/TBranch.cxx b/tree/tree/src/TBranch.cxx index 0e6411343ffc8..acfda89f1677c 100644 --- a/tree/tree/src/TBranch.cxx +++ b/tree/tree/src/TBranch.cxx @@ -2425,7 +2425,7 @@ void TBranch::Print(Option_t *option) const } Printf("*Baskets :%9d : Basket Size=%11d bytes Compression= %6.2f *",fWriteBasket,fBasketSize,cx); - if (strncmp(option,"basketsInfo",strlen("basketsInfo"))==0) { + if (strncmp(option,"basketsInfo",std::char_traits::length("basketsInfo"))==0) { Int_t nbaskets = fWriteBasket; for (Int_t i=0;i::length; Int_t nbranches = fBranches.GetEntriesFast(); - if (strncmp(option,"debugAddress",strlen("debugAddress"))==0) { - if (strlen(option)==strlen("debugAddress")) { + if (strncmp(option,"debugAddress",length("debugAddress"))==0) { + if (strlen(option)==length("debugAddress")) { Printf("%-24s %-16s %2s %4s %-16s %-16s %8s %8s %s %s\n", "Branch Name", "Streamer Class", "ID", "Type", "Class", "Parent", "pOffset", "fOffset", "fObject", "fOnfileObject"); } @@ -3859,7 +3860,7 @@ void TBranchElement::Print(Option_t* option) const } return; } - if (strncmp(option,"debugInfo",strlen("debugInfo"))==0) { + if (strncmp(option,"debugInfo",length("debugInfo"))==0) { Printf("Branch %s uses:",GetName()); if (fID>=0) { // GetInfoImp()->GetElement(fID)->ls(); @@ -3892,7 +3893,7 @@ void TBranchElement::Print(Option_t* option) const if (fFillActionSequence) fFillActionSequence->Print(option); } TString suboption = "debugInfoSub"; - suboption += (option+strlen("debugInfo")); + suboption += (option+length("debugInfo")); for (Int_t i = 0; i < nbranches; ++i) { TBranchElement* subbranch = (TBranchElement*)fBranches.At(i); subbranch->Print(suboption); diff --git a/tree/tree/src/TBranchSTL.cxx b/tree/tree/src/TBranchSTL.cxx index 8ec498a649333..9dd82119b86c0 100644 --- a/tree/tree/src/TBranchSTL.cxx +++ b/tree/tree/src/TBranchSTL.cxx @@ -602,8 +602,9 @@ bool TBranchSTL::IsFolder() const void TBranchSTL::Print(const char *option) const { - if (strncmp(option,"debugAddress",strlen("debugAddress"))==0) { - if (strlen(GetName())>24) Printf("%-24s\n%-24s ", GetName(),""); + constexpr auto length = std::char_traits::length; + if (strncmp(option,"debugAddress",length("debugAddress"))==0) { + if (length(GetName())>24) Printf("%-24s\n%-24s ", GetName(),""); else Printf("%-24s ", GetName()); TBranchElement *parent = dynamic_cast(GetMother()->GetSubBranch(this)); @@ -620,7 +621,7 @@ void TBranchSTL::Print(const char *option) const TBranch *br = (TBranch *)fBranches.UncheckedAt(i); br->Print("debugAddressSub"); } - } else if (strncmp(option,"debugInfo",strlen("debugInfo"))==0) { + } else if (strncmp(option,"debugInfo",length("debugInfo"))==0) { Printf("Branch %s uses:\n",GetName()); if (fID>=0) { GetInfo()->GetElement(fID)->ls(); diff --git a/tree/tree/src/TTree.cxx b/tree/tree/src/TTree.cxx index 41e53481ffe25..fdd0158699aea 100644 --- a/tree/tree/src/TTree.cxx +++ b/tree/tree/src/TTree.cxx @@ -7246,7 +7246,7 @@ void TTree::Print(Option_t* option) const if (!option) option = ""; - if (strncmp(option,"clusters",strlen("clusters"))==0) { + if (strncmp(option,"clusters",std::char_traits::length("clusters"))==0) { Printf("%-16s %-16s %-16s %8s %20s", "Cluster Range #", "Entry Start", "Last Entry", "Size", "Number of clusters"); Int_t index= 0; diff --git a/tree/treeplayer/src/TFormLeafInfo.cxx b/tree/treeplayer/src/TFormLeafInfo.cxx index 0308623957370..2438eff891039 100644 --- a/tree/treeplayer/src/TFormLeafInfo.cxx +++ b/tree/treeplayer/src/TFormLeafInfo.cxx @@ -1020,7 +1020,7 @@ TFormLeafInfoNumerical::TFormLeafInfoNumerical(TVirtualCollectionProxy *collecti if (fKind == TStreamerInfo::kOffsetL + TStreamerInfo::kChar) { // Could be a bool if (strcmp( collection->GetCollectionClass()->GetName(), "vector") == 0 - || strncmp( collection->GetCollectionClass()->GetName(), "bitset<", strlen("bitset<") ) ==0 ) { + || strncmp( collection->GetCollectionClass()->GetName(), "bitset<", std::char_traits::length("bitset<") ) ==0 ) { fIsBool = true; fKind = (EDataType)18; } diff --git a/tree/treeplayer/src/TTreePlayer.cxx b/tree/treeplayer/src/TTreePlayer.cxx index 036153641c6c7..0fe464bd345cb 100644 --- a/tree/treeplayer/src/TTreePlayer.cxx +++ b/tree/treeplayer/src/TTreePlayer.cxx @@ -797,6 +797,7 @@ Int_t TTreePlayer::MakeClass(const char *classname, const char *option) fprintf(fp,"\n// Header file for the classes stored in the TTree if any.\n"); TList listOfHeaders; listOfHeaders.SetOwner(); + constexpr auto length = std::char_traits::length; for (l=0;lUncheckedAt(l); TBranch *branch = leaf->GetBranch(); @@ -812,11 +813,11 @@ Int_t TTreePlayer::MakeClass(const char *classname, const char *option) fprintf(fp,"#include <%s>\n",declfile+precstl_len); listOfHeaders.Add(new TNamed(cl->GetName(),declfile+precstl_len)); } else if (strncmp(declfile,"/usr/include/",13) == 0) { - fprintf(fp,"#include <%s>\n",declfile+strlen("/include/c++/")); - listOfHeaders.Add(new TNamed(cl->GetName(),declfile+strlen("/include/c++/"))); + fprintf(fp,"#include <%s>\n",declfile+length("/include/c++/")); + listOfHeaders.Add(new TNamed(cl->GetName(),declfile+length("/include/c++/"))); } else if (strstr(declfile,"/include/c++/") != nullptr) { - fprintf(fp,"#include <%s>\n",declfile+strlen("/include/c++/")); - listOfHeaders.Add(new TNamed(cl->GetName(),declfile+strlen("/include/c++/"))); + fprintf(fp,"#include <%s>\n",declfile+length("/include/c++/")); + listOfHeaders.Add(new TNamed(cl->GetName(),declfile+length("/include/c++/"))); } else if (strncmp(declfile,rootinclude,rootinclude_len) == 0) { fprintf(fp,"#include <%s>\n",declfile+rootinclude_len); listOfHeaders.Add(new TNamed(cl->GetName(),declfile+rootinclude_len)); @@ -2359,7 +2360,7 @@ void TTreePlayer::RecursiveRemove(TObject *obj) } //////////////////////////////////////////////////////////////////////////////// -/// \brief Loop on Tree and print entries passing selection. Interactive +/// \brief Loop on Tree and print entries passing selection. Interactive /// pagination break is on by default. /// \param varexp If varexp is 0 (or "") then print only first 8 columns. /// If varexp = "*" print all columns. Otherwise a columns selection can @@ -2449,7 +2450,7 @@ Long64_t TTreePlayer::Scan(const char *varexp, const char *selection, Option_t * option, Long64_t nentries, Long64_t firstentry) { - + constexpr auto length = std::char_traits::length; TString opt = option; opt.ToLower(); UInt_t ui; @@ -2461,23 +2462,23 @@ Long64_t TTreePlayer::Scan(const char *varexp, const char *selection, if (opt.Contains("lenmax=")) { int start = opt.Index("lenmax="); - int numpos = start + strlen("lenmax="); + int numpos = start + length("lenmax="); int numlen = 0; int len = opt.Length(); while( (numpos+numlen