Bug 1466449 addendum - Turn jArray from a struct to class and make it have a constructor from nullptr. r=smaug.
authorHenri Sivonen <hsivonen@hsivonen.fi>
Wed, 07 Nov 2018 18:14:28 +0200
changeset 504732 d5227588be64b1713c4f784ff4368e71bc36e263
parent 504731 53412b7c8303e495e7bb191f03ceb9b239f1ebd7
child 504733 01219b0ae60ee8a2f3302ceb1804330caee54abe
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1466449
milestone65.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
Bug 1466449 addendum - Turn jArray from a struct to class and make it have a constructor from nullptr. r=smaug. Simple adding a constructor from nullptr did not compile without turning jArray all the way to a class instead of struct.
parser/html/jArray.h
--- a/parser/html/jArray.h
+++ b/parser/html/jArray.h
@@ -43,19 +43,27 @@ struct staticJArray
   {
     size_t idx;
     bool found = mozilla::BinarySearch(arr, 0, length, elem, &idx);
     return found ? idx : -1;
   }
 };
 
 template<class T, class L>
-struct jArray
+class autoJArray;
+
+template<class T, class L>
+class jArray
 {
+  friend class autoJArray<T, L>;
+
+private:
   T* arr;
+
+public:
   L length;
   static jArray<T, L> newJArray(L const len)
   {
     MOZ_ASSERT(len >= 0, "Negative length.");
     jArray<T, L> newArray = { new T[size_t(len)], len };
     return newArray;
   }
   static jArray<T, L> newFallibleJArray(L const len)
@@ -72,16 +80,33 @@ struct jArray
     MOZ_ASSERT(index < length, "Array index out of bounds.");
     return arr[index];
   }
   void operator=(staticJArray<T, L>& other)
   {
     arr = (T*)other.arr;
     length = other.length;
   }
+  MOZ_IMPLICIT jArray(decltype(nullptr))
+    : arr(nullptr)
+    , length(0)
+  {
+  }
+  jArray()
+    : arr(nullptr)
+    , length(0)
+  {
+  }
+
+private:
+  jArray(T* aArr, L aLength)
+    : arr(aArr)
+    , length(aLength)
+  {
+  }
 };
 
 template<class T, class L>
 class autoJArray
 {
 private:
   T* arr;