Bug 1534593 part 3. Initialize JSObject* entries in Record types. r=qdot
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 16 Apr 2019 19:18:52 +0000
changeset 469842 7e2bcc5233ff4910b859b06b8f8d4fd61c34de57
parent 469841 988efe7f290a677c37ecdd9cf5450632d91e7759
child 469843 e38d7b762244e7a5132bceb13de7e46433287975
push id35883
push userbtara@mozilla.com
push dateWed, 17 Apr 2019 21:47:29 +0000
treeherdermozilla-central@02b89c29412b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersqdot
bugs1534593
milestone68.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 1534593 part 3. Initialize JSObject* entries in Record types. r=qdot Differential Revision: https://phabricator.services.mozilla.com/D27562
dom/bindings/Record.h
--- a/dom/bindings/Record.h
+++ b/dom/bindings/Record.h
@@ -30,16 +30,31 @@ class RecordEntry {
   // Move constructor so we can do Records of Records.
   RecordEntry(RecordEntry<KeyType, ValueType>&& aOther)
       : mKey(std::move(aOther.mKey)), mValue(std::move(aOther.mValue)) {}
 
   KeyType mKey;
   ValueType mValue;
 };
 
+// Specialize for a JSObject* ValueType and initialize it on construction, so we
+// don't need to worry about un-initialized JSObject* floating around.
+template <typename KeyType>
+class RecordEntry<KeyType, JSObject*> {
+ public:
+  RecordEntry() : mValue(nullptr) {}
+
+  // Move constructor so we can do Records of Records.
+  RecordEntry(RecordEntry<KeyType, JSObject*>&& aOther)
+      : mKey(std::move(aOther.mKey)), mValue(std::move(aOther.mValue)) {}
+
+  KeyType mKey;
+  JSObject* mValue;
+};
+
 }  // namespace binding_detail
 
 template <typename KeyType, typename ValueType>
 class Record {
  public:
   typedef typename binding_detail::RecordEntry<KeyType, ValueType> EntryType;
   typedef Record<KeyType, ValueType> SelfType;