Bug 1287006 - Don't pass Nullable by value in various places, rather by const&. r=bz
authorJeff Walden <jwalden@mit.edu>
Mon, 13 Feb 2017 09:07:40 -0800
changeset 342890 91df292ad3ce2453145f53732e243c85808d67a3
parent 342889 deb448009371c6677fb44897f7ca5d03c00739a9
child 342891 07fffe40a02399f715612c2cbd22e9ecbcca6e0e
push id31366
push usercbook@mozilla.com
push dateWed, 15 Feb 2017 11:25:19 +0000
treeherdermozilla-central@c0807d6938c1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1287006
milestone54.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 1287006 - Don't pass Nullable by value in various places, rather by const&. r=bz
dom/bindings/test/TestBindingHeader.h
dom/events/DeviceMotionEvent.cpp
dom/events/DeviceMotionEvent.h
dom/html/HTMLInputElement.cpp
dom/html/HTMLInputElement.h
dom/indexedDB/IDBEvents.cpp
dom/indexedDB/IDBEvents.h
dom/quota/ActorsParent.cpp
dom/quota/QuotaManager.h
--- a/dom/bindings/test/TestBindingHeader.h
+++ b/dom/bindings/test/TestBindingHeader.h
@@ -261,37 +261,37 @@ public:
   void PassOptionalUnsignedLongLong(const Optional<uint64_t>&);
   void PassOptionalUnsignedLongLongWithDefault(uint64_t);
 
   float WritableFloat() const;
   void SetWritableFloat(float);
   float WritableUnrestrictedFloat() const;
   void SetWritableUnrestrictedFloat(float);
   Nullable<float> GetWritableNullableFloat() const;
-  void SetWritableNullableFloat(Nullable<float>);
+  void SetWritableNullableFloat(const Nullable<float>&);
   Nullable<float> GetWritableNullableUnrestrictedFloat() const;
-  void SetWritableNullableUnrestrictedFloat(Nullable<float>);
+  void SetWritableNullableUnrestrictedFloat(const Nullable<float>&);
   double WritableDouble() const;
   void SetWritableDouble(double);
   double WritableUnrestrictedDouble() const;
   void SetWritableUnrestrictedDouble(double);
   Nullable<double> GetWritableNullableDouble() const;
-  void SetWritableNullableDouble(Nullable<double>);
+  void SetWritableNullableDouble(const Nullable<double>&);
   Nullable<double> GetWritableNullableUnrestrictedDouble() const;
-  void SetWritableNullableUnrestrictedDouble(Nullable<double>);
-  void PassFloat(float, float, Nullable<float>, Nullable<float>,
-                 double, double, Nullable<double>, Nullable<double>,
+  void SetWritableNullableUnrestrictedDouble(const Nullable<double>&);
+  void PassFloat(float, float, const Nullable<float>&, const Nullable<float>&,
+                 double, double, const Nullable<double>&, const Nullable<double>&,
                  const Sequence<float>&, const Sequence<float>&,
                  const Sequence<Nullable<float> >&,
                  const Sequence<Nullable<float> >&,
                  const Sequence<double>&, const Sequence<double>&,
                  const Sequence<Nullable<double> >&,
                  const Sequence<Nullable<double> >&);
-  void PassLenientFloat(float, float, Nullable<float>, Nullable<float>,
-                        double, double, Nullable<double>, Nullable<double>,
+  void PassLenientFloat(float, float, const Nullable<float>&, const Nullable<float>&,
+                        double, double, const Nullable<double>&, const Nullable<double>&,
                         const Sequence<float>&, const Sequence<float>&,
                         const Sequence<Nullable<float> >&,
                         const Sequence<Nullable<float> >&,
                         const Sequence<double>&, const Sequence<double>&,
                         const Sequence<Nullable<double> >&,
                         const Sequence<Nullable<double> >&);
   float LenientFloatAttr() const;
   void SetLenientFloatAttr(float);
--- a/dom/events/DeviceMotionEvent.cpp
+++ b/dom/events/DeviceMotionEvent.cpp
@@ -28,33 +28,33 @@ NS_INTERFACE_MAP_END_INHERITING(Event)
 void
 DeviceMotionEvent::InitDeviceMotionEvent(
                      const nsAString& aType,
                      bool aCanBubble,
                      bool aCancelable,
                      const DeviceAccelerationInit& aAcceleration,
                      const DeviceAccelerationInit& aAccelIncludingGravity,
                      const DeviceRotationRateInit& aRotationRate,
-                     Nullable<double> aInterval)
+                     const Nullable<double>& aInterval)
 {
   InitDeviceMotionEvent(aType, aCanBubble, aCancelable, aAcceleration,
                         aAccelIncludingGravity, aRotationRate, aInterval,
                         Nullable<uint64_t>());
 }
 
 void
 DeviceMotionEvent::InitDeviceMotionEvent(
                      const nsAString& aType,
                      bool aCanBubble,
                      bool aCancelable,
                      const DeviceAccelerationInit& aAcceleration,
                      const DeviceAccelerationInit& aAccelIncludingGravity,
                      const DeviceRotationRateInit& aRotationRate,
-                     Nullable<double> aInterval,
-                     Nullable<uint64_t> aTimeStamp)
+                     const Nullable<double>& aInterval,
+                     const Nullable<uint64_t>& aTimeStamp)
 {
   NS_ENSURE_TRUE_VOID(!mEvent->mFlags.mIsBeingDispatched);
 
   Event::InitEvent(aType, aCanBubble, aCancelable);
 
   mAcceleration = new DeviceAcceleration(this, aAcceleration.mX,
                                          aAcceleration.mY,
                                          aAcceleration.mZ);
@@ -110,19 +110,19 @@ DeviceMotionEvent::Constructor(const Glo
  *****************************************************************************/
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DeviceAcceleration, mOwner)
 
 NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(DeviceAcceleration, AddRef)
 NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(DeviceAcceleration, Release)
 
 DeviceAcceleration::DeviceAcceleration(DeviceMotionEvent* aOwner,
-                                       Nullable<double> aX,
-                                       Nullable<double> aY,
-                                       Nullable<double> aZ)
+                                       const Nullable<double>& aX,
+                                       const Nullable<double>& aY,
+                                       const Nullable<double>& aZ)
   : mOwner(aOwner)
   , mX(aX)
   , mY(aY)
   , mZ(aZ)
 {
 }
 
 DeviceAcceleration::~DeviceAcceleration()
@@ -134,19 +134,19 @@ DeviceAcceleration::~DeviceAcceleration(
  *****************************************************************************/
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DeviceRotationRate, mOwner)
 
 NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(DeviceRotationRate, AddRef)
 NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(DeviceRotationRate, Release)
 
 DeviceRotationRate::DeviceRotationRate(DeviceMotionEvent* aOwner,
-                                       Nullable<double> aAlpha,
-                                       Nullable<double> aBeta,
-                                       Nullable<double> aGamma)
+                                       const Nullable<double>& aAlpha,
+                                       const Nullable<double>& aBeta,
+                                       const Nullable<double>& aGamma)
   : mOwner(aOwner)
   , mAlpha(aAlpha)
   , mBeta(aBeta)
   , mGamma(aGamma)
 {
 }
 
 DeviceRotationRate::~DeviceRotationRate()
--- a/dom/events/DeviceMotionEvent.h
+++ b/dom/events/DeviceMotionEvent.h
@@ -16,18 +16,19 @@ namespace dom {
 
 class DeviceRotationRate final : public nsWrapperCache
 {
 public:
   NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DeviceRotationRate)
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DeviceRotationRate)
 
   DeviceRotationRate(DeviceMotionEvent* aOwner,
-                     Nullable<double> aAlpha, Nullable<double> aBeta,
-                     Nullable<double> aGamma);
+                     const Nullable<double>& aAlpha,
+                     const Nullable<double>& aBeta,
+                     const Nullable<double>& aGamma);
 
   DeviceMotionEvent* GetParentObject() const
   {
     return mOwner;
   }
 
   virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
   {
@@ -48,18 +49,19 @@ protected:
 
 class DeviceAcceleration final : public nsWrapperCache
 {
 public:
   NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DeviceAcceleration)
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DeviceAcceleration)
 
   DeviceAcceleration(DeviceMotionEvent* aOwner,
-                     Nullable<double> aX, Nullable<double> aY,
-                     Nullable<double> aZ);
+                     const Nullable<double>& aX,
+                     const Nullable<double>& aY,
+                     const Nullable<double>& aZ);
 
   DeviceMotionEvent* GetParentObject() const
   {
     return mOwner;
   }
 
   virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
   {
@@ -123,27 +125,27 @@ public:
 
   void InitDeviceMotionEvent(
          const nsAString& aType,
          bool aCanBubble,
          bool aCancelable,
          const DeviceAccelerationInit& aAcceleration,
          const DeviceAccelerationInit& aAccelerationIncludingGravity,
          const DeviceRotationRateInit& aRotationRate,
-         Nullable<double> aInterval);
+         const Nullable<double>& aInterval);
 
   void InitDeviceMotionEvent(
          const nsAString& aType,
          bool aCanBubble,
          bool aCancelable,
          const DeviceAccelerationInit& aAcceleration,
          const DeviceAccelerationInit& aAccelerationIncludingGravity,
          const DeviceRotationRateInit& aRotationRate,
-         Nullable<double> aInterval,
-         Nullable<uint64_t> aTimeStamp);
+         const Nullable<double>& aInterval,
+         const Nullable<uint64_t>& aTimeStamp);
 
   static already_AddRefed<DeviceMotionEvent>
   Constructor(const GlobalObject& aGlobal,
               const nsAString& aType,
               const DeviceMotionEventInit& aEventInitDict,
               ErrorResult& aRv);
 
 protected:
--- a/dom/html/HTMLInputElement.cpp
+++ b/dom/html/HTMLInputElement.cpp
@@ -2327,17 +2327,17 @@ HTMLInputElement::GetValueAsDate(ErrorRe
   }
 
   MOZ_ASSERT(false, "Unrecognized input type");
   aRv.Throw(NS_ERROR_UNEXPECTED);
   return Nullable<Date>();
 }
 
 void
-HTMLInputElement::SetValueAsDate(Nullable<Date> aDate, ErrorResult& aRv)
+HTMLInputElement::SetValueAsDate(const Nullable<Date>& aDate, ErrorResult& aRv)
 {
   if (!IsDateTimeInputType(mType)) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
 
   // At this point we know we're not a file input, so we can just pass "not
   // system" as the caller type, since the caller type only matters in the file
--- a/dom/html/HTMLInputElement.h
+++ b/dom/html/HTMLInputElement.h
@@ -664,17 +664,17 @@ public:
   }
 
   void SetValue(const nsAString& aValue, CallerType aCallerType,
                 ErrorResult& aRv);
   void GetValue(nsAString& aValue, CallerType aCallerType);
 
   Nullable<Date> GetValueAsDate(ErrorResult& aRv);
 
-  void SetValueAsDate(Nullable<Date>, ErrorResult& aRv);
+  void SetValueAsDate(const Nullable<Date>& aDate, ErrorResult& aRv);
 
   double ValueAsNumber() const
   {
     return DoesValueAsNumberApply() ? GetValueAsDecimal().toDouble()
                                     : UnspecifiedNaN<double>();
   }
 
   void SetValueAsNumber(double aValue, ErrorResult& aRv);
--- a/dom/indexedDB/IDBEvents.cpp
+++ b/dom/indexedDB/IDBEvents.cpp
@@ -47,17 +47,17 @@ CreateGenericEvent(EventTarget* aOwner,
 
 } // namespace indexedDB
 
 // static
 already_AddRefed<IDBVersionChangeEvent>
 IDBVersionChangeEvent::CreateInternal(EventTarget* aOwner,
                                       const nsAString& aType,
                                       uint64_t aOldVersion,
-                                      Nullable<uint64_t> aNewVersion)
+                                      const Nullable<uint64_t>& aNewVersion)
 {
   RefPtr<IDBVersionChangeEvent> event =
     new IDBVersionChangeEvent(aOwner, aOldVersion);
   if (!aNewVersion.IsNull()) {
     event->mNewVersion.SetValue(aNewVersion.Value());
   }
 
   event->InitEvent(aType, false, false);
--- a/dom/indexedDB/IDBEvents.h
+++ b/dom/indexedDB/IDBEvents.h
@@ -118,17 +118,17 @@ private:
 
   ~IDBVersionChangeEvent()
   { }
 
   static already_AddRefed<IDBVersionChangeEvent>
   CreateInternal(EventTarget* aOwner,
                  const nsAString& aName,
                  uint64_t aOldVersion,
-                 Nullable<uint64_t> aNewVersion);
+                 const Nullable<uint64_t>& aNewVersion);
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(IDBVersionChangeEvent, IDBVERSIONCHANGEEVENT_IID)
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_idbevents_h__
--- a/dom/quota/ActorsParent.cpp
+++ b/dom/quota/ActorsParent.cpp
@@ -254,21 +254,21 @@ class DirectoryLockImpl final
   // Internal quota manager operations use this flag to prevent directory lock
   // registraction/unregistration from updating origin access time, etc.
   const bool mInternal;
 
   bool mInvalidated;
 
 public:
   DirectoryLockImpl(QuotaManager* aQuotaManager,
-                    Nullable<PersistenceType> aPersistenceType,
+                    const Nullable<PersistenceType>& aPersistenceType,
                     const nsACString& aGroup,
                     const OriginScope& aOriginScope,
-                    Nullable<bool> aIsApp,
-                    Nullable<Client::Type> aClientType,
+                    const Nullable<bool>& aIsApp,
+                    const Nullable<Client::Type>& aClientType,
                     bool aExclusive,
                     bool aInternal,
                     OpenDirectoryListener* aOpenListener);
 
   void
   AssertIsOnOwningThread() const
 #ifdef DEBUG
   ;
@@ -915,17 +915,17 @@ public:
   RunImmediately()
   {
     MOZ_ASSERT(GetState() == State_Initial);
 
     MOZ_ALWAYS_SUCCEEDS(this->Run());
   }
 
 protected:
-  NormalOriginOperationBase(Nullable<PersistenceType> aPersistenceType,
+  NormalOriginOperationBase(const Nullable<PersistenceType>& aPersistenceType,
                             const OriginScope& aOriginScope,
                             bool aExclusive)
     : mPersistenceType(aPersistenceType)
     , mOriginScope(aOriginScope)
     , mExclusive(aExclusive)
   {
     AssertIsOnOwningThread();
   }
@@ -2111,21 +2111,21 @@ DeallocPQuotaParent(PQuotaParent* aActor
   return true;
 }
 
 /*******************************************************************************
  * Directory lock
  ******************************************************************************/
 
 DirectoryLockImpl::DirectoryLockImpl(QuotaManager* aQuotaManager,
-                                     Nullable<PersistenceType> aPersistenceType,
+                                     const Nullable<PersistenceType>& aPersistenceType,
                                      const nsACString& aGroup,
                                      const OriginScope& aOriginScope,
-                                     Nullable<bool> aIsApp,
-                                     Nullable<Client::Type> aClientType,
+                                     const Nullable<bool>& aIsApp,
+                                     const Nullable<Client::Type>& aClientType,
                                      bool aExclusive,
                                      bool aInternal,
                                      OpenDirectoryListener* aOpenListener)
   : mQuotaManager(aQuotaManager)
   , mPersistenceType(aPersistenceType)
   , mGroup(aGroup)
   , mOriginScope(aOriginScope)
   , mIsApp(aIsApp)
@@ -2803,21 +2803,21 @@ QuotaManager::Get()
 // static
 bool
 QuotaManager::IsShuttingDown()
 {
   return gShutdown;
 }
 
 auto
-QuotaManager::CreateDirectoryLock(Nullable<PersistenceType> aPersistenceType,
+QuotaManager::CreateDirectoryLock(const Nullable<PersistenceType>& aPersistenceType,
                                   const nsACString& aGroup,
                                   const OriginScope& aOriginScope,
-                                  Nullable<bool> aIsApp,
-                                  Nullable<Client::Type> aClientType,
+                                  const Nullable<bool>& aIsApp,
+                                  const Nullable<Client::Type>& aClientType,
                                   bool aExclusive,
                                   bool aInternal,
                                   OpenDirectoryListener* aOpenListener)
   -> already_AddRefed<DirectoryLockImpl>
 {
   AssertIsOnOwningThread();
   MOZ_ASSERT_IF(aOriginScope.IsOrigin(), !aOriginScope.GetOrigin().IsEmpty());
   MOZ_ASSERT_IF(!aInternal, !aPersistenceType.IsNull());
@@ -4417,19 +4417,19 @@ QuotaManager::OpenDirectory(PersistenceT
                         Nullable<Client::Type>(aClientType),
                         aExclusive,
                         false,
                         aOpenListener);
   MOZ_ASSERT(lock);
 }
 
 void
-QuotaManager::OpenDirectoryInternal(Nullable<PersistenceType> aPersistenceType,
+QuotaManager::OpenDirectoryInternal(const Nullable<PersistenceType>& aPersistenceType,
                                     const OriginScope& aOriginScope,
-                                    Nullable<Client::Type> aClientType,
+                                    const Nullable<Client::Type>& aClientType,
                                     bool aExclusive,
                                     OpenDirectoryListener* aOpenListener)
 {
   AssertIsOnOwningThread();
 
   RefPtr<DirectoryLockImpl> lock =
     CreateDirectoryLock(aPersistenceType,
                         EmptyCString(),
--- a/dom/quota/QuotaManager.h
+++ b/dom/quota/QuotaManager.h
@@ -247,19 +247,19 @@ public:
                 const nsACString& aOrigin,
                 bool aIsApp,
                 Client::Type aClientType,
                 bool aExclusive,
                 OpenDirectoryListener* aOpenListener);
 
   // XXX RemoveMe once bug 1170279 gets fixed.
   void
-  OpenDirectoryInternal(Nullable<PersistenceType> aPersistenceType,
+  OpenDirectoryInternal(const Nullable<PersistenceType>& aPersistenceType,
                         const OriginScope& aOriginScope,
-                        Nullable<Client::Type> aClientType,
+                        const Nullable<Client::Type>& aClientType,
                         bool aExclusive,
                         OpenDirectoryListener* aOpenListener);
 
   // Collect inactive and the least recently used origins.
   uint64_t
   CollectOriginsForEviction(uint64_t aMinSizeToBeFreed,
                             nsTArray<RefPtr<DirectoryLockImpl>>& aLocks);
 
@@ -402,21 +402,21 @@ private:
 
   nsresult
   Init(const nsAString& aBaseDirPath);
 
   void
   Shutdown();
 
   already_AddRefed<DirectoryLockImpl>
-  CreateDirectoryLock(Nullable<PersistenceType> aPersistenceType,
+  CreateDirectoryLock(const Nullable<PersistenceType>& aPersistenceType,
                       const nsACString& aGroup,
                       const OriginScope& aOriginScope,
-                      Nullable<bool> aIsApp,
-                      Nullable<Client::Type> aClientType,
+                      const Nullable<bool>& aIsApp,
+                      const Nullable<Client::Type>& aClientType,
                       bool aExclusive,
                       bool aInternal,
                       OpenDirectoryListener* aOpenListener);
 
   already_AddRefed<DirectoryLockImpl>
   CreateDirectoryLockForEviction(PersistenceType aPersistenceType,
                                  const nsACString& aGroup,
                                  const nsACString& aOrigin,