Bug 1349799 - Add PodEqual(T&,T&). - r=waldo draft
authorJeff Gilbert <jgilbert@mozilla.com>
Fri, 22 Jun 2018 16:45:53 -0700
changeset 809783 c665afc4814a24eb8b2cf2a584cad2327249162f
parent 809776 2211ebb43ed90fdb3641602da83332d4d46949e9
child 809784 7727d35ceb7f112963130088f8312e9ecf53a505
push id113816
push userbmo:jgilbert@mozilla.com
push dateSat, 23 Jun 2018 00:05:09 +0000
reviewerswaldo
bugs1349799
milestone62.0a1
Bug 1349799 - Add PodEqual(T&,T&). - r=waldo MozReview-Commit-ID: JKk0FJChLlp
mfbt/PodOperations.h
--- a/mfbt/PodOperations.h
+++ b/mfbt/PodOperations.h
@@ -186,11 +186,19 @@ PodEqual(const T* one, const T* two, siz
  */
 template <class T, size_t N>
 static MOZ_ALWAYS_INLINE bool
 PodEqual(const T (&one)[N], const T (&two)[N])
 {
   return PodEqual(one, two, N);
 }
 
+/** Compare the raw bytes of two objects of the same type. */
+template<typename T>
+static MOZ_ALWAYS_INLINE bool
+PodEqual(const T& a, const T& b)
+{
+  return !memcmp(&a, &b, sizeof(T));
+}
+
 } // namespace mozilla
 
 #endif /* mozilla_PodOperations_h */