Bug 1100219 - Avoid lots of unnecessary string copying in ProtocolParser. r=neil.
authorNicholas Nethercote <nnethercote@mozilla.com>
Tue, 18 Nov 2014 18:42:43 -0800
changeset 216382 845a77a120995233ad04d68b90442b0f01083f1c
parent 216381 7d2dd850d1f41570b395f51b002ef45e6c393e86
child 216383 ccae5be1b38121752727bf35f2e8c708afa0a7b7
push id52028
push usernnethercote@mozilla.com
push dateWed, 19 Nov 2014 02:43:55 +0000
treeherdermozilla-inbound@845a77a12099 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersneil
bugs1100219
milestone36.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 1100219 - Avoid lots of unnecessary string copying in ProtocolParser. r=neil.
toolkit/components/url-classifier/ProtocolParser.cpp
--- a/toolkit/components/url-classifier/ProtocolParser.cpp
+++ b/toolkit/components/url-classifier/ProtocolParser.cpp
@@ -279,17 +279,17 @@ ProtocolParser::ProcessChunk(bool* aDone
   if (mPending.Length() < mChunkState.length) {
     *aDone = true;
     return NS_OK;
   }
 
   // Pull the chunk out of the pending stream data.
   nsAutoCString chunk;
   chunk.Assign(Substring(mPending, 0, mChunkState.length));
-  mPending = Substring(mPending, mChunkState.length);
+  mPending.Cut(0, mChunkState.length);
 
   *aDone = false;
   mState = PROTOCOL_STATE_CONTROL;
 
   //LOG(("Handling a %d-byte chunk", chunk.Length()));
   if (StringEndsWith(mTableUpdate->TableName(),
                      NS_LITERAL_CSTRING("-shavar"))) {
     return ProcessShaChunk(chunk);
@@ -585,24 +585,24 @@ ProtocolParser::ProcessHostSubComplete(u
 
     mTableUpdate->NewSubComplete(addChunk, hash, mChunkState.num);
   }
 
   return NS_OK;
 }
 
 bool
-ProtocolParser::NextLine(nsACString& line)
+ProtocolParser::NextLine(nsACString& aLine)
 {
   int32_t newline = mPending.FindChar('\n');
   if (newline == kNotFound) {
     return false;
   }
-  line.Assign(Substring(mPending, 0, newline));
-  mPending = Substring(mPending, newline + 1);
+  aLine.Assign(Substring(mPending, 0, newline));
+  mPending.Cut(0, newline + 1);
   return true;
 }
 
 void
 ProtocolParser::CleanupUpdates()
 {
   for (uint32_t i = 0; i < mTableUpdates.Length(); i++) {
     delete mTableUpdates[i];