[gnome-commander] [performance] Pass parameters as reference in utils.h and dict.h



commit b9e7be6115ece4dfbce17218661a8f6140605717
Author: Uwe Scholz <uwescholz src gnome org>
Date:   Sun Oct 2 19:56:16 2016 +0200

    [performance] Pass parameters as reference in utils.h and dict.h

 src/dict.h  |   16 ++++++++--------
 src/utils.h |   12 ++++++------
 2 files changed, 14 insertions(+), 14 deletions(-)
---
diff --git a/src/dict.h b/src/dict.h
index be162ca..d609d02 100644
--- a/src/dict.h
+++ b/src/dict.h
@@ -41,20 +41,20 @@ class DICT
 
   public:
 
-    DICT(const KEY no_key=KEY(), const VAL no_val=VAL()): NO_KEY(no_key), NO_VALUE(no_val)   {}
+    DICT(const KEY &no_key=KEY(), const VAL &no_val=VAL()): NO_KEY(no_key), NO_VALUE(no_val)   {}
 
-    void add(const KEY k, const VAL &v);
-    void add(const VAL v, const KEY &k)             {  add(k,v);  }
+    void add(const KEY &k, const VAL &v);
+    void add(const VAL &v, const KEY &k)             {  add(k,v);  }
 
     void clear()                                    {  k_coll.clear(); v_coll.clear();  }
 
-    const VAL &operator [] (const KEY k) const;
-    const KEY &operator [] (const VAL v) const;
+    const VAL &operator [] (const KEY &k) const;
+    const KEY &operator [] (const VAL &v) const;
 };
 
 
 template <typename KEY, typename VAL>
-inline void DICT<KEY,VAL>::add(const KEY k, const VAL &v)
+inline void DICT<KEY,VAL>::add(const KEY &k, const VAL &v)
 {
     std::pair<typename KEY_COLL::iterator,bool> k_pos = k_coll.insert(std::make_pair(k,(const VAL *) NULL));
     std::pair<typename VAL_COLL::iterator,bool> v_pos = v_coll.insert(std::make_pair(v,(const KEY *) NULL));
@@ -68,7 +68,7 @@ inline void DICT<KEY,VAL>::add(const KEY k, const VAL &v)
 
 
 template <typename KEY, typename VAL>
-inline const VAL &DICT<KEY,VAL>::operator [] (const KEY k) const
+inline const VAL &DICT<KEY,VAL>::operator [] (const KEY &k) const
 {
     typename KEY_COLL::const_iterator pos = k_coll.find(k);
 
@@ -80,7 +80,7 @@ inline const VAL &DICT<KEY,VAL>::operator [] (const KEY k) const
 
 
 template <typename KEY, typename VAL>
-inline const KEY &DICT<KEY,VAL>::operator [] (const VAL v) const
+inline const KEY &DICT<KEY,VAL>::operator [] (const VAL &v) const
 {
     typename VAL_COLL::const_iterator pos = v_coll.find(v);
 
diff --git a/src/utils.h b/src/utils.h
index f3641a2..3708396 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -350,7 +350,7 @@ inline std::string stringify(const T &val)
 int split(const std::string &s, std::vector<std::string> &coll, const char *sep);
 
 template <typename Iterator>
-inline std::ostream &join(std::ostream &os, Iterator beg, Iterator end, const std::string sep=" ")
+inline std::ostream &join(std::ostream &os, Iterator beg, Iterator end, const std::string &sep=" ")
 {
     if (beg==end)  return os;
 
@@ -369,13 +369,13 @@ inline std::ostream &join(std::ostream &os, Iterator beg, Iterator end, const st
 // }
 
 template <typename T, typename Compare, typename Allocator, template <typename, typename, typename> class 
COLL>
-inline std::ostream &join(std::ostream &os, const COLL<T, Compare, Allocator> &coll, const std::string sep=" 
")
+inline std::ostream &join(std::ostream &os, const COLL<T, Compare, Allocator> &coll, const std::string 
&sep=" ")
 {
     return join(os,coll.begin(),coll.end(),sep);
 }
 
 template <typename Iterator>
-inline std::string &join(std::string &s, Iterator beg, Iterator end, const std::string sep=" ")
+inline std::string &join(std::string &s, Iterator beg, Iterator end, const std::string &sep=" ")
 {
     s.clear();
 
@@ -400,13 +400,13 @@ inline std::string &join(std::string &s, Iterator beg, Iterator end, const std::
 // }
 
 template <typename T, typename Compare, typename Allocator, template <typename, typename, typename> class 
COLL>
-inline std::string &join(std::string &s, const COLL<T, Compare, Allocator> &coll, const std::string sep=" ")
+inline std::string &join(std::string &s, const COLL<T, Compare, Allocator> &coll, const std::string &sep=" ")
 {
     return join(s,coll.begin(),coll.end(),sep);
 }
 
 template <typename Iterator>
-inline std::string join(Iterator beg, Iterator end, const std::string sep=" ")
+inline std::string join(Iterator beg, Iterator end, const std::string &sep=" ")
 {
     std::string s;
 
@@ -422,7 +422,7 @@ inline std::string join(Iterator beg, Iterator end, const std::string sep=" ")
 // }
 
 template <typename T, typename Compare, typename Allocator, template <typename, typename, typename> class 
COLL>
-inline std::string join(const COLL<T, Compare, Allocator> &coll, const std::string sep=" ")
+inline std::string join(const COLL<T, Compare, Allocator> &coll, const std::string &sep=" ")
 {
     std::string s;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]