Bug 1381410 (part 5) - Reorder nsStringBundle. r=emk.
authorNicholas Nethercote <nnethercote@mozilla.com>
Mon, 17 Jul 2017 18:37:32 +1000
changeset 418096 8cd4bd9ec8ae107a4c6a178c53aae56668804fbe
parent 418095 3756382ef3b77ecfbd89d142c21e0ed202dfbf6b
child 418097 e3dcb77ea22f1e07a5e5261f73ee9a2563584355
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemk
bugs1381410
milestone56.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 1381410 (part 5) - Reorder nsStringBundle. r=emk. This patch moves the destructor after the constructor, puts the NS_IMPL_ISUPPORTS line in a more sensible spot, and moves the Get*() functions before the Format*() functions in order to match the order in nsIStringBundle.idl.
intl/strres/nsStringBundle.cpp
--- a/intl/strres/nsStringBundle.cpp
+++ b/intl/strres/nsStringBundle.cpp
@@ -31,30 +31,32 @@
 #include "nsIBinaryInputStream.h"
 #include "nsIStringStream.h"
 #endif
 
 using namespace mozilla;
 
 static NS_DEFINE_CID(kErrorServiceCID, NS_ERRORSERVICE_CID);
 
-nsStringBundle::~nsStringBundle()
-{
-}
+NS_IMPL_ISUPPORTS(nsStringBundle, nsIStringBundle)
 
 nsStringBundle::nsStringBundle(const char* aURLSpec,
                                nsIStringBundleOverride* aOverrideStrings) :
   mPropertiesURL(aURLSpec),
   mOverrideStrings(aOverrideStrings),
   mReentrantMonitor("nsStringBundle.mReentrantMonitor"),
   mAttemptedLoad(false),
   mLoaded(false)
 {
 }
 
+nsStringBundle::~nsStringBundle()
+{
+}
+
 nsresult
 nsStringBundle::LoadProperties()
 {
   // this is different than mLoaded, because we only want to attempt
   // to load once
   // we only want to load once, but if we've tried once and failed,
   // continue to throw an error!
   if (mAttemptedLoad) {
@@ -131,16 +133,48 @@ nsStringBundle::GetStringFromNameHelper(
     if (NS_SUCCEEDED(rv)) return rv;
   }
 
   rv = mProps->GetStringProperty(nsDependentCString(aName), aResult);
   return rv;
 }
 
 NS_IMETHODIMP
+nsStringBundle::GetStringFromID(int32_t aID, char16_t **aResult)
+{
+  nsAutoCString idStr;
+  idStr.AppendInt(aID, 10);
+  return GetStringFromName(idStr.get(), aResult);
+}
+
+NS_IMETHODIMP
+nsStringBundle::GetStringFromAUTF8Name(const nsACString& aName,
+                                       char16_t **aResult)
+{
+  return GetStringFromName(PromiseFlatCString(aName).get(), aResult);
+}
+
+NS_IMETHODIMP
+nsStringBundle::GetStringFromName(const char* aName, char16_t** aResult)
+{
+  NS_ENSURE_ARG_POINTER(aResult);
+
+  *aResult = nullptr;
+
+  nsAutoString tmpstr;
+  nsresult rv = GetStringFromNameHelper(aName, tmpstr);
+  if (NS_FAILED(rv)) return rv;
+
+  *aResult = ToNewUnicode(tmpstr);
+  NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
+
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 nsStringBundle::FormatStringFromID(int32_t aID,
                                    const char16_t **aParams,
                                    uint32_t aLength,
                                    char16_t ** aResult)
 {
   nsAutoCString idStr;
   idStr.AppendInt(aID, 10);
   return FormatStringFromName(idStr.get(), aParams, aLength, aResult);
@@ -171,50 +205,16 @@ nsStringBundle::FormatStringFromName(con
 
   nsAutoString formatStr;
   nsresult rv = GetStringFromNameHelper(aName, formatStr);
   if (NS_FAILED(rv)) return rv;
 
   return FormatString(formatStr.get(), aParams, aLength, aResult);
 }
 
-NS_IMPL_ISUPPORTS(nsStringBundle, nsIStringBundle)
-
-NS_IMETHODIMP
-nsStringBundle::GetStringFromID(int32_t aID, char16_t **aResult)
-{
-  nsAutoCString idStr;
-  idStr.AppendInt(aID, 10);
-  return GetStringFromName(idStr.get(), aResult);
-}
-
-NS_IMETHODIMP
-nsStringBundle::GetStringFromAUTF8Name(const nsACString& aName,
-                                       char16_t **aResult)
-{
-  return GetStringFromName(PromiseFlatCString(aName).get(), aResult);
-}
-
-NS_IMETHODIMP
-nsStringBundle::GetStringFromName(const char* aName, char16_t** aResult)
-{
-  NS_ENSURE_ARG_POINTER(aResult);
-
-  *aResult = nullptr;
-
-  nsAutoString tmpstr;
-  nsresult rv = GetStringFromNameHelper(aName, tmpstr);
-  if (NS_FAILED(rv)) return rv;
-
-  *aResult = ToNewUnicode(tmpstr);
-  NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
-
-  return NS_OK;
-}
-
 nsresult
 nsStringBundle::GetCombinedEnumeration(nsIStringBundleOverride* aOverrideStrings,
                                        nsISimpleEnumerator** aResult)
 {
   nsCOMPtr<nsISupports> supports;
   nsCOMPtr<nsIPropertyElement> propElement;
 
   nsresult rv;