msvcrt: Optimize tolower function when locale was never changed.
Signed-off-by: Piotr Caban <piotr@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
ca683382e0
commit
e867af3bfe
|
@ -458,7 +458,9 @@ int CDECL MSVCRT__tolower_l(int c, MSVCRT__locale_t locale)
|
|||
*/
|
||||
int CDECL MSVCRT_tolower(int c)
|
||||
{
|
||||
return MSVCRT__tolower_l(c, NULL);
|
||||
if(initial_locale)
|
||||
return c>='A' && c<='Z' ? c-'A'+'a' : c;
|
||||
return MSVCRT__tolower_l(c, NULL);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
|
|
@ -48,6 +48,7 @@ int MSVCRT___lc_collate_cp = 0;
|
|||
LCID MSVCRT___lc_handle[MSVCRT_LC_MAX - MSVCRT_LC_MIN + 1] = { 0 };
|
||||
int MSVCRT___mb_cur_max = 1;
|
||||
static unsigned char charmax = CHAR_MAX;
|
||||
BOOL initial_locale = TRUE;
|
||||
|
||||
#define MSVCRT_LEADBYTE 0x8000
|
||||
#define MSVCRT_C1_DEFINED 0x200
|
||||
|
@ -1780,6 +1781,9 @@ char* CDECL MSVCRT_setlocale(int category, const char* locale)
|
|||
|
||||
_lock_locales();
|
||||
|
||||
if(locale[0] != 'C' || locale[1] != '\0')
|
||||
initial_locale = FALSE;
|
||||
|
||||
if(locinfo->lc_handle[MSVCRT_LC_COLLATE]!=newlocinfo->lc_handle[MSVCRT_LC_COLLATE]
|
||||
|| locinfo->lc_id[MSVCRT_LC_COLLATE].wCodePage!=newlocinfo->lc_id[MSVCRT_LC_COLLATE].wCodePage) {
|
||||
locinfo->lc_collate_cp = newlocinfo->lc_collate_cp;
|
||||
|
|
|
@ -283,6 +283,7 @@ extern MSVCRT__locale_t MSVCRT_locale DECLSPEC_HIDDEN;
|
|||
extern unsigned int MSVCRT___lc_codepage;
|
||||
extern int MSVCRT___lc_collate_cp;
|
||||
extern WORD MSVCRT__ctype [257];
|
||||
extern BOOL initial_locale DECLSPEC_HIDDEN;
|
||||
|
||||
void msvcrt_set_errno(int) DECLSPEC_HIDDEN;
|
||||
#if _MSVCR_VER >= 80
|
||||
|
|
|
@ -2788,13 +2788,19 @@ static void test_tolower(void)
|
|||
|
||||
errno = 0xdeadbeef;
|
||||
ret = p_tolower((char)0xF4);
|
||||
todo_wine ok(ret == (char)0xF4, "ret = %x\n", ret);
|
||||
todo_wine ok(errno == 0xdeadbeef, "errno = %d\n", errno);
|
||||
ok(ret == (char)0xF4, "ret = %x\n", ret);
|
||||
ok(errno == 0xdeadbeef, "errno = %d\n", errno);
|
||||
|
||||
errno = 0xdeadbeef;
|
||||
ret = p_tolower((char)0xD0);
|
||||
todo_wine ok(ret == (char)0xD0, "ret = %x\n", ret);
|
||||
todo_wine ok(errno == 0xdeadbeef, "errno = %d\n", errno);
|
||||
ok(ret == (char)0xD0, "ret = %x\n", ret);
|
||||
ok(errno == 0xdeadbeef, "errno = %d\n", errno);
|
||||
|
||||
setlocale(LC_ALL, "C");
|
||||
errno = 0xdeadbeef;
|
||||
ret = p_tolower((char)0xF4);
|
||||
ok(ret == (char)0xF4, "ret = %x\n", ret);
|
||||
ok(errno == 0xdeadbeef, "errno = %d\n", errno);
|
||||
|
||||
/* test C locale after setting locale */
|
||||
if(!setlocale(LC_ALL, "us")) {
|
||||
|
|
Loading…
Reference in New Issue