From 2e00bb27d50b1fbee32438f90610224b83cfdfb0 Mon Sep 17 00:00:00 2001
From: abarton <Adam.Edward.Barton@cern.ch>
Date: Thu, 9 Sep 2021 12:31:12 +0100
Subject: [PATCH] String optimizations in Database

---
 .../AthenaPoolCnvSvc/src/AthenaPoolCnvSvc.cxx | 61 +++++++++++--------
 Database/AthenaPOOL/PoolSvc/src/PoolSvc.cxx   | 25 ++++----
 Database/IOVDbSvc/src/Cool2Json.cxx           | 21 ++++---
 Database/IOVDbSvc/src/IOVDbCoolFunctions.cxx  |  4 +-
 Database/IOVDbSvc/src/IOVDbParser.cxx         |  2 +-
 Database/IOVDbSvc/src/IOVDbParser.h           |  2 +-
 .../IOVDbSvc/src/IOVDbStringFunctions.cxx     | 22 ++++---
 Database/IOVDbSvc/src/IOVDbStringFunctions.h  |  2 +-
 .../PersistentDataModel/src/Placement.cxx     | 10 ++-
 Database/PersistentDataModel/src/Token.cxx    |  2 +-
 10 files changed, 90 insertions(+), 61 deletions(-)

diff --git a/Database/AthenaPOOL/AthenaPoolCnvSvc/src/AthenaPoolCnvSvc.cxx b/Database/AthenaPOOL/AthenaPoolCnvSvc/src/AthenaPoolCnvSvc.cxx
index 5160927a0ba4..394b223ba519 100644
--- a/Database/AthenaPOOL/AthenaPoolCnvSvc/src/AthenaPoolCnvSvc.cxx
+++ b/Database/AthenaPOOL/AthenaPoolCnvSvc/src/AthenaPoolCnvSvc.cxx
@@ -75,15 +75,14 @@ StatusCode AthenaPoolCnvSvc::initialize() {
    // Extracting MaxFileSizes for global default and map by Database name.
    for (std::vector<std::string>::const_iterator iter = m_maxFileSizes.value().begin(),
 	   last = m_maxFileSizes.value().end(); iter != last; ++iter) {
-      if (iter->find('=') != std::string::npos) {
-         long long maxFileSize = atoll(iter->substr(iter->find('=') + 1).c_str());
+      if (auto p = iter->find('='); p != std::string::npos) {
+         long long maxFileSize = atoll(iter->data() + (p + 1));
          if (maxFileSize > 15000000000LL) {
             ATH_MSG_INFO("Files larger than 15GB are disallowed by ATLAS policy.");
             ATH_MSG_INFO("They should only be produced for private use or in special cases.");
          }
          std::string databaseName = iter->substr(0, iter->find_first_of(" 	="));
-         std::pair<std::string, long long> entry(databaseName, maxFileSize);
-         m_databaseMaxFileSize.insert(entry);
+         m_databaseMaxFileSize.insert(std::make_pair(databaseName, maxFileSize));
       } else {
          m_domainMaxFileSize = atoll(iter->c_str());
          if (m_domainMaxFileSize > 15000000000LL) {
@@ -187,7 +186,8 @@ StatusCode AthenaPoolCnvSvc::createObj(IOpaqueAddress* pAddress, DataObject*& re
          oss << std::dec << pAddress->clID();
          objName = oss.str();
       }
-      objName += "#" + *(pAddress->par() + 1);
+      objName += '#';
+      objName += *(pAddress->par() + 1);
    }
    if (m_doChronoStat) {
       m_chronoStatSvc->chronoStart("cObj_" + objName);
@@ -217,7 +217,8 @@ StatusCode AthenaPoolCnvSvc::createRep(DataObject* pObject, IOpaqueAddress*& ref
          oss << std::dec << pObject->clID();
          objName = oss.str();
       }
-      objName += "#" + pObject->registry()->name();
+      objName += '#';
+      objName += pObject->registry()->name();
    }
    if (m_doChronoStat) {
       m_chronoStatSvc->chronoStart("cRep_" + objName);
@@ -253,7 +254,8 @@ StatusCode AthenaPoolCnvSvc::fillRepRefs(IOpaqueAddress* pAddress, DataObject* p
          oss << std::dec << pObject->clID();
          objName = oss.str();
       }
-      objName += "#" + pObject->registry()->name();
+      objName += '#';
+      objName += pObject->registry()->name();
    }
    if (m_doChronoStat) {
       m_chronoStatSvc->chronoStart("fRep_" + objName);
@@ -322,7 +324,7 @@ StatusCode AthenaPoolCnvSvc::connectOutput(const std::string& outputConnectionSp
    }
 
    if (!m_outputStreamingTool.empty() && m_outputStreamingTool[0]->isClient() && m_parallelCompression) {
-      outputConnection = outputConnection + m_streamPortString.value();
+      outputConnection +=  m_streamPortString.value();
    }
    unsigned int contextId = outputContextId(outputConnection);
    try {
@@ -344,7 +346,7 @@ StatusCode AthenaPoolCnvSvc::connectOutput(const std::string& outputConnectionSp
       std::vector<std::string> maxFileSize;
       maxFileSize.push_back("TREE_MAX_SIZE");
       maxFileSize.push_back("1099511627776L");
-      m_domainAttr.push_back(maxFileSize);
+      m_domainAttr.emplace_back(std::move(maxFileSize));
       // Extracting OUTPUT POOL ItechnologySpecificAttributes for Domain, Database and Container.
       extractPoolAttributes(m_poolAttr, &m_containerAttr, &m_databaseAttr, &m_domainAttr);
       for (std::vector<std::vector<std::string> >::iterator iter = m_databaseAttr.begin(), last = m_databaseAttr.end();
@@ -359,7 +361,8 @@ StatusCode AthenaPoolCnvSvc::connectOutput(const std::string& outputConnectionSp
          std::size_t colon = m_containerPrefixProp.value().find(':');
          if (colon == std::string::npos) colon = 0; // Used to remove leading technology
          else colon++;
-         if (merge != std::string::npos && opt == "TREE_AUTO_FLUSH" && file == outputConnection.substr(0, merge) && cont.substr(equal) == m_containerPrefixProp.value().substr(colon) && data != "int" && data != "DbLonglong" && data != "double" && data != "string") {
+         const auto& strProp = m_containerPrefixProp.value();
+         if (merge != std::string::npos && opt == "TREE_AUTO_FLUSH" && 0 == outputConnection.compare(0, merge, file) && cont.compare(equal, std::string::npos, strProp, colon) == 0 && data != "int" && data != "DbLonglong" && data != "double" && data != "string") {
             flush = atoi(data.c_str());
             if (flush < 0 && m_numberEventsPerWrite.value() > 0) {
                flush = m_numberEventsPerWrite.value();
@@ -458,7 +461,8 @@ StatusCode AthenaPoolCnvSvc::commitOutput(const std::string& outputConnectionSpe
             }
             std::string tokenStr = placementStr;
             std::string contName = strstr(placementStr, "[CONT=");
-            tokenStr = tokenStr.substr(0, tokenStr.find("[CONT=")) + contName.substr(contName.find(']') + 1);
+            tokenStr = tokenStr.substr(0, tokenStr.find("[CONT="));
+            tokenStr.append(contName, contName.find(']') + 1);
             contName = contName.substr(6, contName.find(']') - 6);
             std::string className = strstr(placementStr, "[PNAME=");
             className = className.substr(7, className.find(']') - 7);
@@ -467,8 +471,8 @@ StatusCode AthenaPoolCnvSvc::commitOutput(const std::string& outputConnectionSpe
             std::ostringstream oss2;
             oss2 << std::dec << num;
             std::string::size_type len = m_metadataContainerProp.value().size();
-            if (len > 0 && contName.substr(0, len) == m_metadataContainerProp.value()
-		            && contName.substr(len, 1) == "(") {
+            if (len > 0 && contName.compare(0, len, m_metadataContainerProp.value()) == 0
+		            && contName[len] == '(') {
                ServiceHandle<IIncidentSvc> incSvc("IncidentSvc", name());
                // For Metadata, before moving to next client, fire file incidents
                if (m_metadataClient != num) {
@@ -495,7 +499,7 @@ StatusCode AthenaPoolCnvSvc::commitOutput(const std::string& outputConnectionSpe
                readToken.setOid(Token::OID_t(num, 0));
                readToken.setAuxString("[PNAME=" + className + "]");
                this->setObjPtr(obj, &readToken); // Pull/read Object out of shared memory
-               if (len == 0 || contName.substr(0, len) != m_metadataContainerProp.value()) {
+               if (len == 0 || contName.compare(0, len, m_metadataContainerProp.value()) != 0) {
                   // Write object
                   Placement placement;
                   placement.fromString(placementStr); placementStr = nullptr;
@@ -515,7 +519,9 @@ StatusCode AthenaPoolCnvSvc::commitOutput(const std::string& outputConnectionSpe
                         return abortSharedWrClients(num);
                      }
                      dataHeaderSeen = true;
-                     dataHeaderID = token->contID() + "/" + oss2.str();
+                     dataHeaderID = token->contID();
+                     dataHeaderID += '/';
+                     dataHeaderID += oss2.str();
                   } else if (dataHeaderSeen) {
                      dataHeaderSeen = false;
                      // next object after DataHeader - may be a DataHeaderForm
@@ -618,7 +624,7 @@ StatusCode AthenaPoolCnvSvc::commitOutput(const std::string& outputConnectionSpe
          doCommit = true;
          ATH_MSG_DEBUG("commitOutput sending data.");
       }
-      outputConnection = outputConnection + m_streamPortString.value();
+      outputConnection += m_streamPortString.value();
    }
    unsigned int contextId = outputContextId(outputConnection);
    if (!processPoolAttributes(m_domainAttr, outputConnection, contextId).isSuccess()) {
@@ -694,7 +700,7 @@ StatusCode AthenaPoolCnvSvc::disconnectOutput(const std::string& outputConnectio
       ATH_MSG_DEBUG("disconnectOutput not SKIPPED for server: " << m_streamServer);
    }
    if (!m_outputStreamingTool.empty() && m_outputStreamingTool[0]->isClient() && m_parallelCompression) {
-      outputConnection = outputConnection + m_streamPortString.value();
+      outputConnection += m_streamPortString.value();
    }
    unsigned int contextId = outputContextId(outputConnection);
    StatusCode sc = m_poolSvc->disconnect(contextId);
@@ -724,8 +730,8 @@ Token* AthenaPoolCnvSvc::registerForWrite(Placement* placement, const void* obj,
    }
    Token* token = nullptr;
    if (!m_outputStreamingTool.empty() && m_outputStreamingTool[0]->isClient()
-	   && (!m_parallelCompression || placement->containerName().substr(0, m_metadataContainerProp.value().size()) == m_metadataContainerProp.value())) {
-      std::string fileName = placement->fileName();
+	   && (!m_parallelCompression || placement->containerName().compare(0, m_metadataContainerProp.value().size(), m_metadataContainerProp.value()) == 0)) {
+      const std::string &fileName = placement->fileName();
       auto it = std::find (m_streamClientFiles.begin(),
                            m_streamClientFiles.end(),
                            fileName);
@@ -737,7 +743,10 @@ Token* AthenaPoolCnvSvc::registerForWrite(Placement* placement, const void* obj,
          streamClient = 0;
       }
       // Lock object
-      std::string placementStr = placement->toString() + "[PNAME=" + classDesc.Name() + "]";
+      std::string placementStr = placement->toString();
+      placementStr += "[PNAME=";
+      placementStr += classDesc.Name();
+      placementStr += ']';
       ATH_MSG_VERBOSE("Requesting write object for: " << placementStr);
       StatusCode sc = m_outputStreamingTool[streamClient]->lockObject(placementStr.c_str());
       while (sc.isRecoverable()) {
@@ -822,7 +831,7 @@ Token* AthenaPoolCnvSvc::registerForWrite(Placement* placement, const void* obj,
          tempToken->setClassID(pool::DbReflex::guid(classDesc));
          token = tempToken; tempToken = nullptr;
       } else if (!m_outputStreamingTool.empty() && !m_outputStreamingTool[0]->isClient() && m_streamServer == m_outputStreamingTool.size()) {
-         std::string fileName = placement->fileName();
+         const std::string &fileName = placement->fileName();
          auto it = std::find (m_streamClientFiles.begin(),
                               m_streamClientFiles.end(),
                               fileName);
@@ -959,7 +968,7 @@ StatusCode AthenaPoolCnvSvc::createAddress(long svcType,
       }
    }
    Token* token = nullptr;
-   if (par[0].substr(0, 3) == "SHM") {
+   if (par[0].compare(0, 3, "SHM") == 0) {
       token = new Token();
       token->setOid(Token::OID_t(ip[0], ip[1]));
       token->setAuxString("[PNAME=" + par[2] + "]");
@@ -1275,7 +1284,7 @@ void AthenaPoolCnvSvc::extractPoolAttributes(const StringArrayProperty& property
             opt.push_back(databaseName);
             if (!containerName.empty()) {
                opt.push_back(containerName);
-               if (containerName.substr(0, 6) == "TTree=") {
+               if (containerName.compare(0, 6, "TTree=") == 0) {
                   dbAttr->push_back(opt);
                } else {
                   contAttr->push_back(opt);
@@ -1332,8 +1341,8 @@ StatusCode AthenaPoolCnvSvc::processPoolAttributes(std::vector<std::vector<std::
          std::string data = (*iter)[1];
          const std::string& file = (*iter)[2];
          const std::string& cont = (*iter)[3];
-         if (!fileName.empty() && (file == fileName.substr(0, fileName.find('?'))
-	         || (file.substr(0, 1) == "*" && file.find("," + fileName + ",") == std::string::npos))) {
+         if (!fileName.empty() && (0 == fileName.compare(0, fileName.find('?'), file)
+	         || (file[0] == '*' && file.find("," + fileName + ",") == std::string::npos))) {
             if (data == "int" || data == "DbLonglong" || data == "double" || data == "string") {
                if (doGet) {
                   if (!m_poolSvc->getAttribute(opt, data, pool::DbType(pool::ROOTTREE_StorageType).type(), fileName, cont, contextId).isSuccess()) {
@@ -1345,7 +1354,7 @@ StatusCode AthenaPoolCnvSvc::processPoolAttributes(std::vector<std::vector<std::
                if (m_poolSvc->setAttribute(opt, data, pool::DbType(pool::ROOTTREE_StorageType).type(), fileName, cont, contextId).isSuccess()) {
                   ATH_MSG_DEBUG("setAttribute " << opt << " to " << data << " for db: " << fileName << " and cont: " << cont);
                   if (doClear) {
-                     if (file.substr(0, 1) == "*" && !m_persSvcPerOutput) {
+                     if (file[0] == '*' && !m_persSvcPerOutput) {
                         (*iter)[2] += "," + fileName + ",";
                      } else {
                         iter->clear();
diff --git a/Database/AthenaPOOL/PoolSvc/src/PoolSvc.cxx b/Database/AthenaPOOL/PoolSvc/src/PoolSvc.cxx
index 9c6a333179cf..f033136bd114 100644
--- a/Database/AthenaPOOL/PoolSvc/src/PoolSvc.cxx
+++ b/Database/AthenaPOOL/PoolSvc/src/PoolSvc.cxx
@@ -822,18 +822,18 @@ StatusCode PoolSvc::setAttribute(const std::string& optName,
          ATH_MSG_DEBUG("Failed to get ContainerHandle to set POOL property.");
          return(StatusCode::FAILURE);
       }
-      if (contName.find('(') != std::string::npos) {
-         objName = contName.substr(contName.find('(') + 1); // Get BranchName between parenthesis
+      if (auto p = contName.find('('); p != std::string::npos) {
+         objName = contName.substr(p + 1); // Get BranchName between parenthesis
          objName = objName.substr(0, objName.find(')'));
-      } else if (contName.find("::") != std::string::npos) {
-         objName = contName.substr(contName.find("::") + 2); // Split off Tree name
-      } else if (contName.find('_') != std::string::npos) {
-         objName = contName.substr(contName.find('_') + 1); // Split off "POOLContainer"
+      } else if (auto p = contName.find("::"); p != std::string::npos) {
+         objName = contName.substr(p + 2); // Split off Tree name
+      } else if (auto p = contName.find('_'); p != std::string::npos) {
+         objName = contName.substr(p + 1); // Split off "POOLContainer"
          objName = objName.substr(0, objName.find('/')); // Split off key
       }
       std::string::size_type off = 0;
       while ((off = objName.find_first_of("<>/")) != std::string::npos) {
-         objName.replace(off, 1, "_"); // Replace special chars (e.g. templates)
+         objName[off] = '_'; // Replace special chars (e.g. templates)
       }
       if (data[data.size() - 1] == 'L') {
          retError = contH->technologySpecificAttributes().setAttribute<long long int>(optName, atoll(data.c_str()), objName);
@@ -970,11 +970,11 @@ std::unique_ptr<pool::IDatabase> PoolSvc::getDbHandle(unsigned int contextId, co
          return(nullptr);
       }
    }
-   if (dbName.find("PFN:") == 0) {
+   if (dbName.compare(0, 4,"PFN:") == 0) {
       dbH = sesH.databaseHandle(dbName.substr(4), pool::DatabaseSpecification::PFN);
-   } else if (dbName.find("LFN:") == 0) {
+   } else if (dbName.compare(0, 4, "LFN:") == 0) {
       dbH = sesH.databaseHandle(dbName.substr(4), pool::DatabaseSpecification::LFN);
-   } else if (dbName.find("FID:") == 0) {
+   } else if (dbName.compare(0, 4,"FID:") == 0) {
       dbH = sesH.databaseHandle(dbName.substr(4), pool::DatabaseSpecification::FID);
    } else {
       dbH = sesH.databaseHandle(dbName, pool::DatabaseSpecification::PFN);
@@ -1006,11 +1006,12 @@ std::string PoolSvc::poolCondPath(const std::string& leaf) {
    const char* cpath = getenv("ATLAS_POOLCOND_PATH");
    if (cpath && strcmp(cpath, "") != 0) {
       std::string testpath = cpath;
-      testpath += "/" + leaf;
+      testpath += '/';
+      testpath += leaf;
       struct stat stFileInfo;
       // try to retrieve file attribute - success indicates file exists
       if (stat(testpath.c_str(), &stFileInfo) == 0) {
-         respath = testpath;
+         respath = std::move(testpath);
       }
    }
    return(respath);
diff --git a/Database/IOVDbSvc/src/Cool2Json.cxx b/Database/IOVDbSvc/src/Cool2Json.cxx
index 979fea669722..57b9fa13ba98 100644
--- a/Database/IOVDbSvc/src/Cool2Json.cxx
+++ b/Database/IOVDbSvc/src/Cool2Json.cxx
@@ -43,9 +43,13 @@ namespace {
     for (unsigned int i(0); i<rspec.size();++i){
       if (i==1) sep=", ";
       const auto & f = rspec[i];
-      result+=sep+f.name()+": "+f.storageType().name();
+      result+=sep;
+      result+=f.name();
+      result+=": ";
+      result+=f.storageType().name();
     }
-    result+="\""+cb;
+    result+='\"';
+    result+=cb;
     return result;
   }
 }
@@ -75,7 +79,10 @@ namespace IOVDbNamespace {
   std::string 
   Cool2Json::description() const{
     std::string saneXml=sanitiseXml(m_desc);
-    return "\"node_description\" : \""+saneXml+"\"";
+    std::string out = "\"node_description\" : \"";
+    out += saneXml;
+    out += '\"';
+    return out;
   }
 
   std::string 
@@ -132,9 +139,9 @@ namespace IOVDbNamespace {
         result+=" a_data_value";
       }
       if (sep.empty()) sep=",";
-      result+="}";
+      result+='}';
     }
-    result+="]";
+    result+=']';
     itr->close();
     return result;
   }
@@ -166,14 +173,14 @@ namespace IOVDbNamespace {
     cool::IRecordIterator& pitr=ref.payloadIterator();
     auto pvec=pitr.fetchAllAsVector();
     std::string sep="";
-    os+="[";//vector of vectors
+    os+='[';//vector of vectors
     for (const auto & vitr:*pvec){
       os+=sep;
       const coral::AttributeList& atrlist=(vitr)->attributeList();
       os+=jsonAttributeList(atrlist);
       if (sep.empty()) sep =", ";
     }
-    os+="]";
+    os+=']';
     return os;
   }
   
diff --git a/Database/IOVDbSvc/src/IOVDbCoolFunctions.cxx b/Database/IOVDbSvc/src/IOVDbCoolFunctions.cxx
index 1339aec4d69d..68d698ff7826 100644
--- a/Database/IOVDbSvc/src/IOVDbCoolFunctions.cxx
+++ b/Database/IOVDbSvc/src/IOVDbCoolFunctions.cxx
@@ -151,7 +151,7 @@ namespace IOVDbNamespace{
     multiversion=(fldPtr->versioningMode()==cool::FolderVersioning::MULTI_VERSION);
     // read and process description string
     folderdesc=fldPtr->description();
-    return std::make_pair(multiversion, folderdesc);
+    return std::make_pair(multiversion, std::move(folderdesc));
   }
   
   
@@ -180,7 +180,7 @@ namespace IOVDbNamespace{
     } else {
       channelNumbers=fldPtr->listChannels();
     }
-    return std::make_pair(channelNumbers, channelNames);
+    return std::make_pair(std::move(channelNumbers), std::move(channelNames));
   }
   
 }
diff --git a/Database/IOVDbSvc/src/IOVDbParser.cxx b/Database/IOVDbSvc/src/IOVDbParser.cxx
index e6ce1b1fa1e0..5fd9f2756770 100644
--- a/Database/IOVDbSvc/src/IOVDbParser.cxx
+++ b/Database/IOVDbSvc/src/IOVDbParser.cxx
@@ -9,7 +9,7 @@
 #include "IOVDbParser.h"
 #include "IOVDbStringFunctions.h"
 
-IOVDbParser::IOVDbParser(const std::string& input, MsgStream& log) :
+IOVDbParser::IOVDbParser(std::string_view input, MsgStream& log) :
   m_msg(log),
   m_valid(true)
 {
diff --git a/Database/IOVDbSvc/src/IOVDbParser.h b/Database/IOVDbSvc/src/IOVDbParser.h
index 6a1d4f6d238a..dc68fb53d3a5 100644
--- a/Database/IOVDbSvc/src/IOVDbParser.h
+++ b/Database/IOVDbSvc/src/IOVDbParser.h
@@ -20,7 +20,7 @@ class IOVDbParser {
 public:
 
   IOVDbParser() = delete; 
-  IOVDbParser(const std::string& input, MsgStream& log);
+  IOVDbParser( std::string_view input, MsgStream& log);
   bool isValid() const;
   ///'at' accessor with an optional default; the bool is true if the key was found
   std::pair<std::string, bool>
diff --git a/Database/IOVDbSvc/src/IOVDbStringFunctions.cxx b/Database/IOVDbSvc/src/IOVDbStringFunctions.cxx
index 29fd17833019..d668c54b4a01 100644
--- a/Database/IOVDbSvc/src/IOVDbStringFunctions.cxx
+++ b/Database/IOVDbSvc/src/IOVDbStringFunctions.cxx
@@ -8,14 +8,14 @@
 
 namespace IOVDbNamespace{
   std::string 
-  spaceStrip(const std::string& input){
+  spaceStrip( std::string_view input){
     // return the input string stripped of leading/trailing spaces
     std::string::size_type idx1=input.find_first_not_of(" \n\r\t");
     std::string::size_type idx2=input.find_last_not_of(" \n\r\t");
     if (idx1==std::string::npos || idx2==std::string::npos) {
       return "";
     } else {
-      return input.substr(idx1,1+idx2-idx1);
+      return std::string(input.substr(idx1,1+idx2-idx1));
     }
   }
   
@@ -85,8 +85,12 @@ namespace IOVDbNamespace{
   
   std::string
   quote(const std::string & sentence){
-    const std::string q("\"");
-    return q+sentence+q;
+    std::string out;
+    out.reserve(sentence.size() + 2);
+    out += '\"';
+    out += sentence;
+    out += '\"';
+    return out;
   }
   
   std::string
@@ -111,7 +115,7 @@ namespace IOVDbNamespace{
   
   std::string
   replaceNULL(const std::string & possibleNULL){
-    std::string original{possibleNULL};
+    const std::string &original{possibleNULL};
     const std::string regex=R"delim( NULL)delim";
     const std::regex nullre(regex);
     const std::string result = std::regex_replace(original,nullre," null");
@@ -168,7 +172,7 @@ namespace IOVDbNamespace{
     //regex: 
     //(anything except colon, multiple times) then _possibly_ (two colons and string of anything except colons)
     // anything except colon) then (colon or end-of-line)
-    std::string linkRegexStr{"([^:]*(::[^:]*)?)(:|$)"};
+    const std::string linkRegexStr{"([^:]*(::[^:]*)?)(:|$)"};
     std::regex linkMatchSpec(linkRegexStr); 
     //give a token iterator using the regex and returning the first substring (i.e. the 
     //bit before a single colon or line end, which would be for example "ALink" or "MyContext::AnotherLink" )
@@ -183,14 +187,16 @@ namespace IOVDbNamespace{
   
   std::pair<std::string, std::string>
   tag2PrefixTarget(const std::vector<std::string> & tagParseResults){
-    std::string prefix{}, target{};
+    std::pair<std::string, std::string> pair;
+    std::string &prefix{pair.first};
+    std::string &target{pair.second};
     if (tagParseResults.size() == 4){ //4 is the size of result set if there is a prefix
       prefix = tagParseResults[2]; //index of first path
       target = tagParseResults[3]; //index of second path
     } else {
       target = tagParseResults[2];
     }
-    return std::make_pair(prefix, target);
+    return pair;
   }
   
   bool
diff --git a/Database/IOVDbSvc/src/IOVDbStringFunctions.h b/Database/IOVDbSvc/src/IOVDbStringFunctions.h
index 4cdaf2da193c..13f6ce0f9ea5 100644
--- a/Database/IOVDbSvc/src/IOVDbStringFunctions.h
+++ b/Database/IOVDbSvc/src/IOVDbStringFunctions.h
@@ -21,7 +21,7 @@ namespace IOVDbNamespace{
 
   ///Trim leading and trailing spaces,return a new trimmed string
   std::string 
-  spaceStrip(const std::string& input);
+  spaceStrip( std::string_view input);
   
   ///Produce a channel number from the string; default to 'defchan' if empty
   int 
diff --git a/Database/PersistentDataModel/src/Placement.cxx b/Database/PersistentDataModel/src/Placement.cxx
index 084d642ff6a5..98d4fff4306e 100755
--- a/Database/PersistentDataModel/src/Placement.cxx
+++ b/Database/PersistentDataModel/src/Placement.cxx
@@ -15,7 +15,13 @@ Placement::Placement() : m_technology(0L), m_fileName(""), m_containerName("") {
 const std::string Placement::toString() const {
    char text[128];
    sprintf(text, fmt_tech, m_technology);
-   std::string str = "[FILE=" + m_fileName + "][CONT=" + m_containerName + "]" + text + m_auxString;
+   std::string str = "[FILE=";
+   str += m_fileName;
+   str += "][CONT=";
+   str += m_containerName;
+   str += ']';
+   str += text;
+   str += m_auxString;
    return str;
 }
 
@@ -36,7 +42,7 @@ Placement& Placement::fromString(const std::string& source) {
             }
             if (!p3) p3 = source.c_str() + source.size();
             m_auxString.append (p1, p3-p1);
-            m_auxString += "]";
+            m_auxString += ']';
          }
       }
    }
diff --git a/Database/PersistentDataModel/src/Token.cxx b/Database/PersistentDataModel/src/Token.cxx
index 32275c402348..0746e15a60d4 100755
--- a/Database/PersistentDataModel/src/Token.cxx
+++ b/Database/PersistentDataModel/src/Token.cxx
@@ -151,7 +151,7 @@ Token& Token::fromString(const std::string& source)    {
             }
             if (!p3) p3 = source.c_str() + source.size();
             m_auxString.append (p1, p3-p1);
-            m_auxString += "]";
+            m_auxString += ']';
          }
       }
    }
-- 
GitLab