From 701d71e04aa25a6ddddd8e5c495573a31a66194c Mon Sep 17 00:00:00 2001
From: Danny Hindson <danny.hindson@stfc.ac.uk>
Date: Mon, 30 Mar 2020 15:08:26 +0100
Subject: [PATCH] Improve definition\management of string parameters to
 functions

---
 Framework/Kernel/inc/MantidKernel/AttenuationProfile.h | 4 ++--
 Framework/Kernel/inc/MantidKernel/MaterialXMLParser.h  | 3 ++-
 Framework/Kernel/src/AttenuationProfile.cpp            | 4 ++--
 Framework/Kernel/src/Material.cpp                      | 2 +-
 Framework/Kernel/src/MaterialBuilder.cpp               | 2 +-
 Framework/Kernel/src/MaterialXMLParser.cpp             | 2 +-
 6 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/Framework/Kernel/inc/MantidKernel/AttenuationProfile.h b/Framework/Kernel/inc/MantidKernel/AttenuationProfile.h
index 324066a9c27..32b8817f2db 100644
--- a/Framework/Kernel/inc/MantidKernel/AttenuationProfile.h
+++ b/Framework/Kernel/inc/MantidKernel/AttenuationProfile.h
@@ -15,8 +15,8 @@ namespace Kernel {
 
 class MANTID_KERNEL_DLL AttenuationProfile {
 public:
-  AttenuationProfile(const std::string inputFileName,
-                     const std::string searchPath);
+  AttenuationProfile(const std::string &inputFileName,
+                     const std::string &searchPath);
   double getAttenuationCoefficient(const double lambda) const;
 
 private:
diff --git a/Framework/Kernel/inc/MantidKernel/MaterialXMLParser.h b/Framework/Kernel/inc/MantidKernel/MaterialXMLParser.h
index aca27293b2c..927d176675e 100644
--- a/Framework/Kernel/inc/MantidKernel/MaterialXMLParser.h
+++ b/Framework/Kernel/inc/MantidKernel/MaterialXMLParser.h
@@ -27,7 +27,8 @@ public:
   static constexpr const char *MATERIAL_TAG = "material";
 
   Material parse(std::istream &istr) const;
-  Material parse(Poco::XML::Element *node, std::string XMLFilePath = "") const;
+  Material parse(Poco::XML::Element *node,
+                 const std::string &XMLFilePath = "") const;
 };
 
 } // namespace Kernel
diff --git a/Framework/Kernel/src/AttenuationProfile.cpp b/Framework/Kernel/src/AttenuationProfile.cpp
index 82a07243ad3..555f10817d5 100644
--- a/Framework/Kernel/src/AttenuationProfile.cpp
+++ b/Framework/Kernel/src/AttenuationProfile.cpp
@@ -20,8 +20,8 @@ namespace Kernel {
  * profile data. Filename can be a full path or just file name
  * @param searchPath :: Path to search for the input file
  */
-AttenuationProfile::AttenuationProfile(const std::string inputFileName,
-                                       const std::string searchPath) {
+AttenuationProfile::AttenuationProfile(const std::string &inputFileName,
+                                       const std::string &searchPath) {
   Poco::Path suppliedFileName(inputFileName);
   Poco::Path inputFilePath;
   std::string fileExt = suppliedFileName.getExtension();
diff --git a/Framework/Kernel/src/Material.cpp b/Framework/Kernel/src/Material.cpp
index 89ce8accac7..caa446ea512 100644
--- a/Framework/Kernel/src/Material.cpp
+++ b/Framework/Kernel/src/Material.cpp
@@ -182,7 +182,7 @@ void Material::calculateTotalScatterXSection() {
 }
 
 void Material::setAttenuationProfile(AttenuationProfile attenuationOverride) {
-  m_attenuationOverride = attenuationOverride;
+  m_attenuationOverride = std::move(attenuationOverride);
 }
 
 /**
diff --git a/Framework/Kernel/src/MaterialBuilder.cpp b/Framework/Kernel/src/MaterialBuilder.cpp
index 68e22aa36f0..cd40c87bf4e 100644
--- a/Framework/Kernel/src/MaterialBuilder.cpp
+++ b/Framework/Kernel/src/MaterialBuilder.cpp
@@ -228,7 +228,7 @@ MaterialBuilder::setAttenuationProfileFilename(std::string filename) {
  * @param path Path to search
  */
 void MaterialBuilder::setAttenuationSearchPath(std::string path) {
-  m_attenuationFileSearchPath = path;
+  m_attenuationFileSearchPath = std::move(path);
 }
 
 /**
diff --git a/Framework/Kernel/src/MaterialXMLParser.cpp b/Framework/Kernel/src/MaterialXMLParser.cpp
index f1f822fe70c..bebaafd01d5 100644
--- a/Framework/Kernel/src/MaterialXMLParser.cpp
+++ b/Framework/Kernel/src/MaterialXMLParser.cpp
@@ -206,7 +206,7 @@ Material MaterialXMLParser::parse(std::istream &istr) const {
  * @return A new Material object
  */
 Material MaterialXMLParser::parse(Poco::XML::Element *element,
-                                  std::string XMLFilePath) const {
+                                  const std::string &XMLFilePath) const {
   using namespace Poco::XML;
   using NamedNodeMapPtr = AutoPtr<NamedNodeMap>;
   NamedNodeMapPtr attrs = element->attributes();
-- 
GitLab