DenseMapInfo pass by reference

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

DenseMapInfo pass by reference

Bakhvalov, Denis via cfe-dev
Hello,

Today, I discovered that all specializations of DenseMapInfo pass by
const reference where I would have used pass by value. For instance:

template<> struct DenseMapInfo<char> {
   static inline char getEmptyKey() { return ~0; }
   static inline char getTombstoneKey() { return ~0 - 1; }
   static unsigned getHashValue(const char& Val) { return Val * 37U; }
   static bool isEqual(const char &LHS, const char &RHS) {
     return LHS == RHS;
   }
};

Do you know why?

---

Loïc Joly


_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: DenseMapInfo pass by reference

Bakhvalov, Denis via cfe-dev
Probably copy pasting from other DenseMapInfo over larger types?

On Thu, Feb 14, 2019 at 9:43 AM Loïc Joly via cfe-dev <[hidden email]> wrote:
Hello,

Today, I discovered that all specializations of DenseMapInfo pass by
const reference where I would have used pass by value. For instance:

template<> struct DenseMapInfo<char> {
   static inline char getEmptyKey() { return ~0; }
   static inline char getTombstoneKey() { return ~0 - 1; }
   static unsigned getHashValue(const char& Val) { return Val * 37U; }
   static bool isEqual(const char &LHS, const char &RHS) {
     return LHS == RHS;
   }
};

Do you know why?

---

Loïc Joly


_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev