vpd:pass vector by reference to avoid copy of vector

When the vector is moved from one class to another, it doesn't
solve the other purpose where the vector data is required after
moving it. In these cases we have to create a local copy of vector
before moving it.

In order to avoid local copy of vector, instead of moving it,
this commit simply passes the vector by reference which solves
all purpose.

Signed-off-by: PriyangaRamasamy <priyanga24@in.ibm.com>
Change-Id: I29f632651107d65a30e2eca785c9d5ee3ea4042a
diff --git a/ibm_vpd_app.cpp b/ibm_vpd_app.cpp
index d8f8cd4..d7f32a8 100644
--- a/ibm_vpd_app.cpp
+++ b/ibm_vpd_app.cpp
@@ -996,7 +996,7 @@
         try
         {
             Binary vpdVector = getVpdDataInVector(js, file);
-            ParserInterface* parser = ParserFactory::getParser(move(vpdVector));
+            ParserInterface* parser = ParserFactory::getParser(vpdVector);
 
             variant<KeywordVpdMap, Store> parseResult;
             parseResult = parser->parse();
diff --git a/impl.hpp b/impl.hpp
index 6dca5e0..dff6aa7 100644
--- a/impl.hpp
+++ b/impl.hpp
@@ -68,7 +68,7 @@
      *
      *  @param[in] vpdBuffer - Binary VPD
      */
-    explicit Impl(Binary&& vpdBuffer) : vpd(std::move(vpdBuffer)), out{}
+    explicit Impl(const Binary& vpdBuffer) : vpd(vpdBuffer), out{}
     {
     }
 
@@ -157,7 +157,7 @@
     openpower::vpd::constants::RecordOffset getVtocOffset() const;
 
     /** @brief VPD in binary format */
-    Binary vpd;
+    const Binary& vpd;
 
     /** @brief parser output */
     Parsed out;
diff --git a/vpd-manager/editor_impl.cpp b/vpd-manager/editor_impl.cpp
index 091d026..1b9290d 100644
--- a/vpd-manager/editor_impl.cpp
+++ b/vpd-manager/editor_impl.cpp
@@ -652,8 +652,7 @@
     Byte vpdType = *iterator;
     if (vpdType == KW_VAL_PAIR_START_TAG)
     {
-        ParserInterface* Iparser =
-            ParserFactory::getParser(std::move(completeVPDFile));
+        ParserInterface* Iparser = ParserFactory::getParser(completeVPDFile);
         IpzVpdParser* ipzParser = dynamic_cast<IpzVpdParser*>(Iparser);
 
         try
diff --git a/vpd-parser/ipz_parser.cpp b/vpd-parser/ipz_parser.cpp
index 5af3441..1f0e341 100644
--- a/vpd-parser/ipz_parser.cpp
+++ b/vpd-parser/ipz_parser.cpp
@@ -15,14 +15,14 @@
 
 std::variant<kwdVpdMap, Store> IpzVpdParser::parse()
 {
-    Impl p(std::move(vpd));
+    Impl p(vpd);
     Store s = p.run();
     return s;
 }
 
 void IpzVpdParser::processHeader()
 {
-    Impl p(std::move(vpd));
+    Impl p(vpd);
     p.checkVPDHeader();
 }
 
diff --git a/vpd-parser/ipz_parser.hpp b/vpd-parser/ipz_parser.hpp
index cb8c489..a4d031b 100644
--- a/vpd-parser/ipz_parser.hpp
+++ b/vpd-parser/ipz_parser.hpp
@@ -32,7 +32,7 @@
     /**
      * @brief Constructor
      */
-    IpzVpdParser(Binary&& VpdVector) : vpd(std::move(VpdVector))
+    IpzVpdParser(const Binary& VpdVector) : vpd(VpdVector)
     {
     }
 
@@ -58,7 +58,7 @@
     void processHeader();
 
   private:
-    Binary vpd;
+    const Binary& vpd;
 }; // class IpzVpdParser
 
 } // namespace parser
diff --git a/vpd-parser/keyword_vpd_parser.hpp b/vpd-parser/keyword_vpd_parser.hpp
index 2382a5f..e48e7d5 100644
--- a/vpd-parser/keyword_vpd_parser.hpp
+++ b/vpd-parser/keyword_vpd_parser.hpp
@@ -49,8 +49,8 @@
      *
      * Move kwVpdVector to parser object's kwVpdVector
      */
-    KeywordVpdParser(openpower::vpd::Binary&& kwVpdVector) :
-        keywordVpdVector(std::move(kwVpdVector))
+    KeywordVpdParser(const openpower::vpd::Binary& kwVpdVector) :
+        keywordVpdVector(kwVpdVector)
     {
     }
 
@@ -73,15 +73,15 @@
     std::string getInterfaceName() const;
 
   private:
-    openpower::vpd::Binary::iterator
+    openpower::vpd::Binary::const_iterator
         checkSumStart; //!< Pointer to the start byte from where
                        //!< the checksum need to be calculated
-    openpower::vpd::Binary::iterator
+    openpower::vpd::Binary::const_iterator
         checkSumEnd; //!< Pointer to the end byte until which the
                      //!< checksum need to be calculated
-    openpower::vpd::Binary::iterator
+    openpower::vpd::Binary::const_iterator
         kwVpdIterator; //!< Iterator to parse the vector
-    openpower::vpd::Binary
+    const openpower::vpd::Binary&
         keywordVpdVector; //!< Vector which stores keyword VPD data
 
     /**
diff --git a/vpd-parser/memory_vpd_parser.hpp b/vpd-parser/memory_vpd_parser.hpp
index 1b7c9e6..27efafe 100644
--- a/vpd-parser/memory_vpd_parser.hpp
+++ b/vpd-parser/memory_vpd_parser.hpp
@@ -30,7 +30,7 @@
      *
      * Move memVpdVector to parser object's memVpdVector
      */
-    memoryVpdParser(Binary&& VpdVector) : memVpd(std::move(VpdVector))
+    memoryVpdParser(const Binary& VpdVector) : memVpd(VpdVector)
     {
     }
 
@@ -59,7 +59,7 @@
     kwdVpdMap readKeywords(Binary::const_iterator iterator);
 
     // vdp file to be parsed
-    Binary memVpd;
+    const Binary& memVpd;
 };
 } // namespace parser
 } // namespace memory
diff --git a/vpd-parser/parser_factory.cpp b/vpd-parser/parser_factory.cpp
index 0489ef1..cc587a7 100644
--- a/vpd-parser/parser_factory.cpp
+++ b/vpd-parser/parser_factory.cpp
@@ -22,7 +22,7 @@
 {
 namespace factory
 {
-interface::ParserInterface* ParserFactory::getParser(Binary&& vpdVector)
+interface::ParserInterface* ParserFactory::getParser(const Binary& vpdVector)
 {
     vpdType type = vpdTypeCheck(vpdVector);
 
@@ -30,17 +30,17 @@
     {
         case IPZ_VPD:
         {
-            return new IpzVpdParser(std::move(vpdVector));
+            return new IpzVpdParser(vpdVector);
         }
 
         case KEYWORD_VPD:
         {
-            return new KeywordVpdParser(std::move(vpdVector));
+            return new KeywordVpdParser(vpdVector);
         }
 
         case MEMORY_VPD:
         {
-            return new memoryVpdParser(std::move(vpdVector));
+            return new memoryVpdParser(vpdVector);
         }
 
         default:
diff --git a/vpd-parser/parser_factory.hpp b/vpd-parser/parser_factory.hpp
index c66e42b..4dbd6a7 100644
--- a/vpd-parser/parser_factory.hpp
+++ b/vpd-parser/parser_factory.hpp
@@ -32,7 +32,7 @@
      * @param[in] - vpd file to check for the type.
      * @return - Pointer to concrete parser class object.
      */
-    static interface::ParserInterface* getParser(Binary&& vpdVector);
+    static interface::ParserInterface* getParser(const Binary& vpdVector);
 
     /**
      * @brief A method to delete the parser object.