Bug 1534593 part 3. Initialize JSObject* entries in Record types. r=qdot a=abillings
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 16 Apr 2019 19:18:52 +0000
changeset 526230 cf8b04d3bfcd51a9ad12a4aab9afb84b9dc74fbd
parent 526229 499c3102dc05f7654036438d2da12fc0565e6ff5
child 526231 f764410a33268a980b26ee16cdf7c746c332f4e3
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersqdot, abillings
bugs1534593
milestone67.0
Bug 1534593 part 3. Initialize JSObject* entries in Record types. r=qdot a=abillings 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;