Bug 1133063 - Move SetLength into the if's condition. r=froydnj
authorTiti_Alone <titou125@gmx.com>
Thu, 26 Feb 2015 19:13:59 +0100
changeset 266688 44495ed6c6188f209b86943f544e6d3b6bd604da
parent 266687 88b311e87678e6224ddf2bd1b1031df56db6ed66
child 266689 8fff872add3102e966afd90517715447fb1afd6d
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1133063
milestone39.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 1133063 - Move SetLength into the if's condition. r=froydnj
xpcom/io/Base64.cpp
xpcom/io/nsScriptableBase64Encoder.cpp
--- a/xpcom/io/Base64.cpp
+++ b/xpcom/io/Base64.cpp
@@ -175,18 +175,17 @@ EncodeInputStream(nsIInputStream* aInput
   uint64_t countlong =
     (count64 + 2) / 3 * 4; // +2 due to integer math.
   if (countlong + aOffset > UINT32_MAX) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   uint32_t count = uint32_t(countlong);
 
-  aDest.SetLength(count + aOffset);
-  if (aDest.Length() != count + aOffset) {
+  if (!aDest.SetLength(count + aOffset, mozilla::fallible)) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   EncodeInputStream_State<T> state;
   state.charsOnStack = 0;
   state.c[2] = '\0';
   state.buffer = aOffset + aDest.BeginWriting();
 
--- a/xpcom/io/nsScriptableBase64Encoder.cpp
+++ b/xpcom/io/nsScriptableBase64Encoder.cpp
@@ -12,21 +12,19 @@ using namespace mozilla;
 NS_IMPL_ISUPPORTS(nsScriptableBase64Encoder, nsIScriptableBase64Encoder)
 
 /* ACString encodeToCString (in nsIInputStream stream, in unsigned long length); */
 NS_IMETHODIMP
 nsScriptableBase64Encoder::EncodeToCString(nsIInputStream* aStream,
                                            uint32_t aLength,
                                            nsACString& aResult)
 {
-  Base64EncodeInputStream(aStream, aResult, aLength);
-  return NS_OK;
+  return Base64EncodeInputStream(aStream, aResult, aLength);
 }
 
 /* AString encodeToString (in nsIInputStream stream, in unsigned long length); */
 NS_IMETHODIMP
 nsScriptableBase64Encoder::EncodeToString(nsIInputStream* aStream,
                                           uint32_t aLength,
                                           nsAString& aResult)
 {
-  Base64EncodeInputStream(aStream, aResult, aLength);
-  return NS_OK;
+  return Base64EncodeInputStream(aStream, aResult, aLength);
 }