Bug 1297804 - part 3 - avoid array bounds checking when writing nsTArray<T> to messages; r=billm
authorNathan Froyd <froydnj@gmail.com>
Fri, 02 Sep 2016 16:14:28 -0400
changeset 312435 af44291ba592257c4ced0a91ba77ca448bb6bb42
parent 312434 92bd6c9ee5f54528a5c56b2bbe612e6f9ce7a5b4
child 312436 1b874fea3cbcc1895dc5e97bd31582c920b6909f
push id30643
push userkwierso@gmail.com
push dateFri, 02 Sep 2016 20:19:12 +0000
treeherdermozilla-central@63d190efe42e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs1297804
milestone51.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 1297804 - part 3 - avoid array bounds checking when writing nsTArray<T> to messages; r=billm We know we're not going to perform out-of bounds accesses here.
ipc/glue/IPCMessageUtils.h
--- a/ipc/glue/IPCMessageUtils.h
+++ b/ipc/glue/IPCMessageUtils.h
@@ -443,18 +443,19 @@ struct ParamTraits<nsTArray<E>>
     uint32_t length = aParam.Length();
     WriteParam(aMsg, length);
 
     if (sUseWriteBytes) {
       int pickledLength = 0;
       MOZ_RELEASE_ASSERT(ByteLengthIsValid(length, sizeof(E), &pickledLength));
       aMsg->WriteBytes(aParam.Elements(), pickledLength);
     } else {
+      const E* elems = aParam.Elements();
       for (uint32_t index = 0; index < length; index++) {
-        WriteParam(aMsg, aParam[index]);
+        WriteParam(aMsg, elems[index]);
       }
     }
   }
 
   // This method uses infallible allocation so that an OOM failure will
   // show up as an OOM crash rather than an IPC FatalError.
   static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
   {