Add a RangedPtr constructor accepting an array as a shorthand for RangedPtr(arr, N). rs=luke
authorJeff Walden <jwalden@mit.edu>
Tue, 07 Jun 2011 13:25:36 -0700
changeset 71415 ac8fceaec76c3c9d0d79b87a1ef3d937ec69f043
parent 71414 21ab818fcdf6816654c2abe64e774b5a6529db2a
child 71416 830f03c194a9b91242e08e269bbd85c6e4c9a54c
child 71461 6ce2bc0be5d03710b83e9935d7d794e91a6e576b
push id45
push userffxbld
push dateThu, 22 Sep 2011 17:29:26 +0000
treeherdermozilla-release@b3273da80b44 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
milestone7.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
Add a RangedPtr constructor accepting an array as a shorthand for RangedPtr(arr, N). rs=luke
mfbt/RangedPtr.h
--- a/mfbt/RangedPtr.h
+++ b/mfbt/RangedPtr.h
@@ -118,16 +118,27 @@ class RangedPtr
       , rangeStart(p), rangeEnd(p + length)
 #endif
     {
         MOZ_ASSERT(length <= size_t(-1) / sizeof(T));
         MOZ_ASSERT(uintptr_t(rangeStart) + length * sizeof(T) >= uintptr_t(rangeStart));
         checkSanity();
     }
 
+    /* Equivalent to RangedPtr(arr, arr, N). */
+    template<size_t N>
+    RangedPtr(T arr[N])
+      : ptr(arr)
+#ifdef DEBUG
+      , rangeStart(arr), rangeEnd(arr + N)
+#endif
+    {
+      checkSanity();
+    }
+
     T* get() const {
         return ptr;
     }
 
     /*
      * You can only assign one RangedPtr into another if the two pointers have
      * the same valid range:
      *