Bug 1453134 - part 1 - add a string input stream constructor that accepts move references; r=baku

This method is more efficient when we know we're not going to need the
string afterwards, and should cut down on intermediate allocations.
This commit is contained in:
Nathan Froyd
2018-04-11 10:06:17 -04:00
parent 99d8814e91
commit 0018264d57
11 changed files with 53 additions and 17 deletions

View File

@@ -782,8 +782,9 @@ FSTextPlain::GetEncodedSubmission(nsIURI* aURI,
ConvertLineBreaks(cbody.get(),
nsLinebreakConverter::eLinebreakAny,
nsLinebreakConverter::eLinebreakNet));
uint32_t bodyLength = cbody.Length();
nsCOMPtr<nsIInputStream> bodyStream;
rv = NS_NewCStringInputStream(getter_AddRefs(bodyStream), cbody);
rv = NS_NewCStringInputStream(getter_AddRefs(bodyStream), Move(cbody));
if (!bodyStream) {
return NS_ERROR_OUT_OF_MEMORY;
}
@@ -797,7 +798,7 @@ FSTextPlain::GetEncodedSubmission(nsIURI* aURI,
mimeStream->SetData(bodyStream);
CallQueryInterface(mimeStream, aPostDataStream);
*aPostDataStreamLength = cbody.Length();
*aPostDataStreamLength = bodyLength;
}
return rv;