b=856850 add PodMove r=Waldo
authorKarl Tomlinson <karlt+@karlt.net>
Tue, 05 Nov 2013 13:02:54 +1300
changeset 168070 9d6f42dd7e5457add0d5f14b97c81aab481ac6e4
parent 168069 d3a78254b14b28e2e18680984205468236a5b12e
child 168071 14c14da0145694382cfb082c9e550a9fcb685b97
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo
bugs856850
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
b=856850 add PodMove r=Waldo
mfbt/PodOperations.h
--- a/mfbt/PodOperations.h
+++ b/mfbt/PodOperations.h
@@ -129,16 +129,31 @@ PodCopy(volatile T* dst, const volatile 
 template <class T, size_t N>
 static void
 PodArrayCopy(T (&dst)[N], const T (&src)[N])
 {
   PodCopy(dst, src, N);
 }
 
 /**
+ * Copy the memory for |nelem| T elements from |src| to |dst|.  If the two
+ * memory ranges overlap, then the effect is as if the |nelem| elements are
+ * first copied from |src| to a temporary array, and then from the temporary
+ * array to |dst|.
+ */
+template<typename T>
+MOZ_ALWAYS_INLINE static void
+PodMove(T* dst, const T* src, size_t nelem)
+{
+  MOZ_ASSERT(nelem <= SIZE_MAX / sizeof(T),
+             "trying to move an impossible number of elements");
+  memmove(dst, src, nelem * sizeof(T));
+}
+
+/**
  * Determine whether the |len| elements at |one| are memory-identical to the
  * |len| elements at |two|.
  */
 template<typename T>
 MOZ_ALWAYS_INLINE static bool
 PodEqual(const T* one, const T* two, size_t len)
 {
   if (len < 128) {