Bug 1172584 - Avoid coping FallibleTArray in SendRequestRunnable constructor. r=dragana
authorBirunthan Mohanathas <birunthan@mohanathas.com>
Mon, 08 Jun 2015 10:52:14 -0700
changeset 278947 1c0391c519686041ec868f4fd5e9fb15a545a612
parent 278946 f2f35acc27a255e85342462341f55cda36c3de65
child 278948 909a9c552fb9e616a42385d7db360187681cddde
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdragana
bugs1172584
milestone41.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 1172584 - Avoid coping FallibleTArray in SendRequestRunnable constructor. r=dragana
netwerk/base/nsUDPSocket.cpp
--- a/netwerk/base/nsUDPSocket.cpp
+++ b/netwerk/base/nsUDPSocket.cpp
@@ -1250,20 +1250,20 @@ PendingSendStream::OnLookupComplete(nsIC
 
   return NS_OK;
 }
 
 class SendRequestRunnable: public nsRunnable {
 public:
   SendRequestRunnable(nsUDPSocket *aSocket,
                       const NetAddr &aAddr,
-                      FallibleTArray<uint8_t> &aData)
+                      FallibleTArray<uint8_t>&& aData)
     : mSocket(aSocket)
     , mAddr(aAddr)
-    , mData(aData)
+    , mData(Move(aData))
   { }
 
   NS_DECL_NSIRUNNABLE
 
 private:
   nsRefPtr<nsUDPSocket> mSocket;
   const NetAddr mAddr;
   FallibleTArray<uint8_t> mData;
@@ -1368,18 +1368,19 @@ nsUDPSocket::SendWithAddress(const NetAd
     this->AddOutputBytes(count);
     *_retval = count;
   } else {
     FallibleTArray<uint8_t> fallibleArray;
     if (!fallibleArray.InsertElementsAt(0, aData, aDataLength, fallible)) {
       return NS_ERROR_OUT_OF_MEMORY;
     }
 
-    nsresult rv = mSts->Dispatch(new SendRequestRunnable(this, *aAddr, fallibleArray),
-                                 NS_DISPATCH_NORMAL);
+    nsresult rv = mSts->Dispatch(
+      new SendRequestRunnable(this, *aAddr, Move(fallibleArray)),
+      NS_DISPATCH_NORMAL);
     NS_ENSURE_SUCCESS(rv, rv);
     *_retval = aDataLength;
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsUDPSocket::SendBinaryStream(const nsACString &aHost, uint16_t aPort,