Alexandre Julliard : kernelbase: Avoid redundant locale lookups in GetLocaleInfoA().
Alexandre Julliard
julliard at winehq.org
Mon Apr 11 15:54:59 CDT 2022
Module: wine
Branch: master
Commit: fd2ecee06fe9ab3af09854bb72fe9be3ec40a673
URL: https://source.winehq.org/git/wine.git/?a=commit;h=fd2ecee06fe9ab3af09854bb72fe9be3ec40a673
Author: Alexandre Julliard <julliard at winehq.org>
Date: Mon Apr 11 17:19:52 2022 +0200
kernelbase: Avoid redundant locale lookups in GetLocaleInfoA().
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/kernelbase/locale.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/dlls/kernelbase/locale.c b/dlls/kernelbase/locale.c
index 1e477a449e1..67052af7e4f 100644
--- a/dlls/kernelbase/locale.c
+++ b/dlls/kernelbase/locale.c
@@ -5098,6 +5098,7 @@ INT WINAPI DECLSPEC_HOTPATCH GetGeoInfoW( GEOID id, GEOTYPE type, WCHAR *data, i
*/
INT WINAPI DECLSPEC_HOTPATCH GetLocaleInfoA( LCID lcid, LCTYPE lctype, char *buffer, INT len )
{
+ const NLS_LOCALE_DATA *locale;
WCHAR *bufferW;
INT lenW, ret;
@@ -5113,19 +5114,26 @@ INT WINAPI DECLSPEC_HOTPATCH GetLocaleInfoA( LCID lcid, LCTYPE lctype, char *buf
SetLastError( ERROR_INVALID_FLAGS );
return 0;
}
-
+ if (!(locale = NlsValidateLocale( &lcid, 0 )))
+ {
+ SetLastError( ERROR_INVALID_PARAMETER );
+ return 0;
+ }
if (LOWORD(lctype) == LOCALE_FONTSIGNATURE || (lctype & LOCALE_RETURN_NUMBER))
- return GetLocaleInfoW( lcid, lctype, (WCHAR *)buffer, len / sizeof(WCHAR) ) * sizeof(WCHAR);
+ {
+ ret = get_locale_info( locale, lcid, lctype, (WCHAR *)buffer, len / sizeof(WCHAR) );
+ return ret * sizeof(WCHAR);
+ }
- if (!(lenW = GetLocaleInfoW( lcid, lctype, NULL, 0 ))) return 0;
+ if (!(lenW = get_locale_info( locale, lcid, lctype, NULL, 0 ))) return 0;
if (!(bufferW = RtlAllocateHeap( GetProcessHeap(), 0, lenW * sizeof(WCHAR) )))
{
SetLastError( ERROR_NOT_ENOUGH_MEMORY );
return 0;
}
- ret = GetLocaleInfoW( lcid, lctype, bufferW, lenW );
- if (ret) ret = WideCharToMultiByte( get_lcid_codepage( lcid, lctype ), 0,
+ ret = get_locale_info( locale, lcid, lctype, bufferW, lenW );
+ if (ret) ret = WideCharToMultiByte( get_locale_codepage( locale, lctype ), 0,
bufferW, ret, buffer, len, NULL, NULL );
RtlFreeHeap( GetProcessHeap(), 0, bufferW );
return ret;
More information about the wine-cvs
mailing list