Bug 815671 part 2. Make some content code use array references instead of array objects with implicit copies. r=smaug
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 29 Nov 2012 11:14:13 -0500 (2012-11-29)
changeset 114501 6469b7a5ea10bac0a29e356947aed14083ac4f05
parent 114500 9cc4fa4f431b9dc3fce8cac4669912edaa780a70
child 114502 0bba55aab571ba62e91fa69f69d6ff89131806a3
push id18805
push userbzbarsky@mozilla.com
push dateThu, 29 Nov 2012 16:15:25 +0000 (2012-11-29)
treeherdermozilla-inbound@a56c5c4bb2bd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs815671
milestone20.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 815671 part 2. Make some content code use array references instead of array objects with implicit copies. r=smaug
content/base/src/nsDOMBlobBuilder.h
content/events/src/nsDOMTouchEvent.cpp
content/html/content/src/nsHTMLFormElement.cpp
--- a/content/base/src/nsDOMBlobBuilder.h
+++ b/content/base/src/nsDOMBlobBuilder.h
@@ -20,17 +20,17 @@ public:
                      const nsAString& aName,
                      const nsAString& aContentType)
     : nsDOMFile(aName, aContentType, UINT64_MAX),
       mBlobs(aBlobs)
   {
   }
 
   // Create as a blob
-  nsDOMMultipartFile(nsTArray<nsCOMPtr<nsIDOMBlob> > aBlobs,
+  nsDOMMultipartFile(nsTArray<nsCOMPtr<nsIDOMBlob> >& aBlobs,
                      const nsAString& aContentType)
     : nsDOMFile(aContentType, UINT64_MAX),
       mBlobs(aBlobs)
   {
   }
 
   // Create as a file to be later initialized
   nsDOMMultipartFile(const nsAString& aName)
--- a/content/events/src/nsDOMTouchEvent.cpp
+++ b/content/events/src/nsDOMTouchEvent.cpp
@@ -283,17 +283,17 @@ nsDOMTouchEvent::GetTouches(nsIDOMTouchL
   if (mTouches) {
     return CallQueryInterface(mTouches, aTouches);
   }
 
   nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(mEvent);
   if (mEvent->message == NS_TOUCH_END || mEvent->message == NS_TOUCH_CANCEL) {
     // for touchend events, remove any changed touches from the touches array
     nsTArray<nsCOMPtr<nsIDOMTouch> > unchangedTouches;
-    nsTArray<nsCOMPtr<nsIDOMTouch> > touches = touchEvent->touches;
+    const nsTArray<nsCOMPtr<nsIDOMTouch> >& touches = touchEvent->touches;
     for (uint32_t i = 0; i < touches.Length(); ++i) {
       if (!touches[i]->mChanged) {
         unchangedTouches.AppendElement(touches[i]);
       }
     }
     t = new nsDOMTouchList(unchangedTouches);
   } else {
     t = new nsDOMTouchList(touchEvent->touches);
@@ -309,17 +309,17 @@ nsDOMTouchEvent::GetTargetTouches(nsIDOM
   NS_ENSURE_STATE(mEvent);
 
   if (mTargetTouches) {
     return CallQueryInterface(mTargetTouches, aTargetTouches);
   }
 
   nsTArray<nsCOMPtr<nsIDOMTouch> > targetTouches;
   nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(mEvent);
-  nsTArray<nsCOMPtr<nsIDOMTouch> > touches = touchEvent->touches;
+  const nsTArray<nsCOMPtr<nsIDOMTouch> >& touches = touchEvent->touches;
   for (uint32_t i = 0; i < touches.Length(); ++i) {
     // for touchend/cancel events, don't append to the target list if this is a
     // touch that is ending
     if ((mEvent->message != NS_TOUCH_END &&
          mEvent->message != NS_TOUCH_CANCEL) || !touches[i]->mChanged) {
       nsIDOMEventTarget* targetPtr = touches[i]->GetTarget();
       if (targetPtr == mEvent->originalTarget) {
         targetTouches.AppendElement(touches[i]);
@@ -337,17 +337,17 @@ nsDOMTouchEvent::GetChangedTouches(nsIDO
   NS_ENSURE_STATE(mEvent);
 
   if (mChangedTouches) {
     return CallQueryInterface(mChangedTouches, aChangedTouches);
   }
 
   nsTArray<nsCOMPtr<nsIDOMTouch> > changedTouches;
   nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(mEvent);
-  nsTArray<nsCOMPtr<nsIDOMTouch> > touches = touchEvent->touches;
+  const nsTArray<nsCOMPtr<nsIDOMTouch> >& touches = touchEvent->touches;
   for (uint32_t i = 0; i < touches.Length(); ++i) {
     if (touches[i]->mChanged) {
       changedTouches.AppendElement(touches[i]);
     }
   }
   mChangedTouches = new nsDOMTouchList(changedTouches);
   return CallQueryInterface(mChangedTouches, aChangedTouches);
 }
--- a/content/html/content/src/nsHTMLFormElement.cpp
+++ b/content/html/content/src/nsHTMLFormElement.cpp
@@ -447,26 +447,27 @@ nsHTMLFormElement::BindToTree(nsIDocumen
   if (htmlDoc) {
     htmlDoc->AddedForm();
   }
 
   return rv;
 }
 
 static void
-MarkOrphans(const nsTArray<nsGenericHTMLFormElement*> aArray)
+MarkOrphans(const nsTArray<nsGenericHTMLFormElement*>& aArray)
 {
   uint32_t length = aArray.Length();
   for (uint32_t i = 0; i < length; ++i) {
     aArray[i]->SetFlags(MAYBE_ORPHAN_FORM_ELEMENT);
   }
 }
 
 static void
-CollectOrphans(nsINode* aRemovalRoot, nsTArray<nsGenericHTMLFormElement*> aArray
+CollectOrphans(nsINode* aRemovalRoot,
+               const nsTArray<nsGenericHTMLFormElement*>& aArray
 #ifdef DEBUG
                , nsIDOMHTMLFormElement* aThisForm
 #endif
                )
 {
   // Put a script blocker around all the notifications we're about to do.
   nsAutoScriptBlocker scriptBlocker;