Bug 1520952. Fix DataMutex constructor to avoid a copy. r=froydnj
authorJeff Muizelaar <jrmuizel@gmail.com>
Fri, 18 Jan 2019 01:32:40 +0000
changeset 514448 5fdaf215ab1242bf140b2139f516f940096ceebe
parent 514447 e3a8a7245f627e6697056a18847f286c0a1d2bc9
child 514449 6c6fecd533820b4b31507307a2e3a70f1887fe23
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1520952
milestone66.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 1520952. Fix DataMutex constructor to avoid a copy. r=froydnj Differential Revision: https://phabricator.services.mozilla.com/D16915
xpcom/threads/DataMutex.h
--- a/xpcom/threads/DataMutex.h
+++ b/xpcom/threads/DataMutex.h
@@ -2,16 +2,17 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef DataMutex_h__
 #define DataMutex_h__
 
+#include <utility>
 #include "mozilla/Mutex.h"
 
 namespace mozilla {
 
 // A template to wrap a type with a mutex so that accesses to the type's
 // data are required to take the lock before accessing it. This ensures
 // that a mutex is explicitly associated with the data that it protects,
 // and makes it impossible to access the data without first taking the
@@ -76,17 +77,17 @@ class DataMutex {
     }
 
     DataMutex<T>* mOwner;
   };
 
  public:
   explicit DataMutex(const char* aName) : mMutex(aName) {}
 
-  DataMutex(T&& aValue, const char* aName) : mMutex(aName), mValue(aValue) {}
+  DataMutex(T&& aValue, const char* aName) : mMutex(aName), mValue(std::move(aValue)) {}
 
   AutoLock Lock() { return AutoLock(this); }
 
  private:
   Mutex mMutex;
   T mValue;
 };