Lots of performance improvements

(In the voice of the kid from sixth sense) I see string copies...

Apparently there are a lot of places we make unnecessary copies. This
fixes all of them.

Not sure how to split this up into smaller patches, or if it even needs
split up. It seems pretty easy to review to me, because basically every
diff is identical.

Change-Id: I22b4ae4f96f7e4082d2bc701098a04f7bed95369
Signed-off-by: Ed Tanous <ed@tanous.net>
Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com>
diff --git a/include/ibm/locks.hpp b/include/ibm/locks.hpp
index b897fa7..201085f 100644
--- a/include/ibm/locks.hpp
+++ b/include/ibm/locks.hpp
@@ -15,7 +15,6 @@
 namespace ibm_mc_lock
 {
 
-namespace fs = std::filesystem;
 using SType = std::string;
 
 /*----------------------------------------
@@ -68,7 +67,7 @@
      * Returns : False (if not a Valid lock request)
      */
 
-    virtual bool isValidLockRequest(const LockRequest);
+    virtual bool isValidLockRequest(const LockRequest&);
 
     /*
      * This function implements the logic of checking if the incoming
@@ -78,7 +77,7 @@
      * Returns : False (if not conflicting)
      */
 
-    virtual bool isConflictRequest(const LockRequests);
+    virtual bool isConflictRequest(const LockRequests&);
     /*
      * Implements the core algorithm to find the conflicting
      * lock requests.
@@ -89,7 +88,7 @@
      * Returns : True (if conflicting)
      * Returns : False (if not conflicting)
      */
-    virtual bool isConflictRecord(const LockRequest, const LockRequest);
+    virtual bool isConflictRecord(const LockRequest&, const LockRequest&);
 
     /*
      * This function implements the logic of checking the conflicting
@@ -98,7 +97,7 @@
      *
      */
 
-    virtual Rc isConflictWithTable(const LockRequests);
+    virtual Rc isConflictWithTable(const LockRequests&);
     /*
      * This function implements the logic of checking the ownership of the
      * lock from the releaselock request.
@@ -153,7 +152,7 @@
      *
      */
 
-    RcAcquireLock acquireLock(const LockRequests);
+    RcAcquireLock acquireLock(const LockRequests&);
 
     /*
      * This function implements the logic for releasing the lock that are
@@ -260,9 +259,10 @@
     }
     std::ofstream persistentFile(fileName);
     // set the permission of the file to 640
-    fs::perms permission =
-        fs::perms::owner_read | fs::perms::owner_write | fs::perms::group_read;
-    fs::permissions(fileName, permission);
+    std::filesystem::perms permission = std::filesystem::perms::owner_read |
+                                        std::filesystem::perms::owner_write |
+                                        std::filesystem::perms::group_read;
+    std::filesystem::permissions(fileName, permission);
     nlohmann::json data;
     for (const auto& it : lockTable)
     {
@@ -329,7 +329,7 @@
     return std::make_pair(true, status);
 }
 
-inline RcAcquireLock Lock::acquireLock(const LockRequests lockRequestStructure)
+inline RcAcquireLock Lock::acquireLock(const LockRequests& lockRequestStructure)
 {
 
     // validate the lock request
@@ -466,7 +466,7 @@
     return true;
 }
 
-inline bool Lock::isValidLockRequest(const LockRequest refLockRecord)
+inline bool Lock::isValidLockRequest(const LockRequest& refLockRecord)
 {
 
     // validate the locktype
@@ -534,7 +534,7 @@
     return true;
 }
 
-inline Rc Lock::isConflictWithTable(const LockRequests refLockRequestStructure)
+inline Rc Lock::isConflictWithTable(const LockRequests& refLockRequestStructure)
 {
 
     uint32_t transactionId;
@@ -588,7 +588,7 @@
     return std::make_pair(false, transactionId);
 }
 
-inline bool Lock::isConflictRequest(const LockRequests refLockRequestStructure)
+inline bool Lock::isConflictRequest(const LockRequests& refLockRequestStructure)
 {
     // check for all the locks coming in as a part of single request
     // return conflict if any two lock requests are conflicting
@@ -647,8 +647,8 @@
     return true;
 }
 
-inline bool Lock::isConflictRecord(const LockRequest refLockRecord1,
-                                   const LockRequest refLockRecord2)
+inline bool Lock::isConflictRecord(const LockRequest& refLockRecord1,
+                                   const LockRequest& refLockRecord2)
 {
     // No conflict if both are read locks