Bug 422789: reduce narrow windows API calls in uconv/, original patch by Brad Lassey <blassey@mozilla.com>, r=smontagu
authorBrian Crowder <crowder@fiverocks.com>
Mon, 11 Aug 2008 15:11:48 -0700
changeset 16564 f5016884eec41d3372914e99f1ee6a113dd8c3c4
parent 16563 a2837ff832c9b960313d6c8a172680241d075b8d
child 16565 cdeb3b9d9b0f10cb30f2121a74c525fe18ebb8a4
push id1137
push userbcrowder@mozilla.com
push dateMon, 11 Aug 2008 22:12:30 +0000
treeherdermozilla-central@f5016884eec4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmontagu
bugs422789
milestone1.9.1a2pre
Bug 422789: reduce narrow windows API calls in uconv/, original patch by Brad Lassey <blassey@mozilla.com>, r=smontagu
intl/uconv/src/nsWinCharset.cpp
--- a/intl/uconv/src/nsWinCharset.cpp
+++ b/intl/uconv/src/nsWinCharset.cpp
@@ -126,37 +126,38 @@ nsPlatformCharset::GetCharset(nsPlatform
 {
   oResult = mCharset;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsPlatformCharset::GetDefaultCharsetForLocale(const nsAString& localeName, nsACString& oResult)
 {
-  nsCOMPtr<nsIWin32Locale>	winLocale;
-  LCID						localeAsLCID;
-  char						acp_name[6];
+  nsCOMPtr<nsIWin32Locale>  winLocale;
+  LCID                      localeAsLCID;
 
   //
   // convert locale name to a code page (through the LCID)
   //
   nsresult rv;
   oResult.Truncate();
 
   winLocale = do_GetService(NS_WIN32LOCALE_CONTRACTID, &rv);
   if (NS_FAILED(rv)) { return rv; }
 
   rv = winLocale->GetPlatformLocale(localeName, &localeAsLCID);
   if (NS_FAILED(rv)) { return rv; }
 
-  if (GetLocaleInfo(localeAsLCID, LOCALE_IDEFAULTANSICODEPAGE, acp_name, sizeof(acp_name))==0) { 
+  PRUnichar acp_name[6];
+  if (GetLocaleInfoW(localeAsLCID, LOCALE_IDEFAULTANSICODEPAGE, acp_name,
+                     NS_ARRAY_LENGTH(acp_name))==0) {
     return NS_ERROR_FAILURE; 
   }
   nsAutoString acp_key(NS_LITERAL_STRING("acp."));
-  acp_key.AppendWithConversion(acp_name);
+  acp_key.Append(acp_name);
 
   return MapToCharset(acp_key, oResult);
 }
 
 NS_IMETHODIMP 
 nsPlatformCharset::Init()
 {
   return NS_OK;