Commit e9eec98d authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Cache locale string to LCID conversion results.

parent b9557e92
......@@ -217,10 +217,17 @@ extern int atoi(const char *);
/* Internal: Find the LCID for a locale specification */
LCID MSVCRT_locale_to_LCID(const char *locale, unsigned short *codepage)
{
thread_data_t *data = msvcrt_get_thread_data();
LCID lcid;
locale_search_t search;
const char *cp, *region;
if (!strcmp(locale, data->cached_locale)) {
if (codepage)
*codepage = data->cached_cp;
return data->cached_lcid;
}
memset(&search, 0, sizeof(locale_search_t));
cp = strchr(locale, '.');
......@@ -292,6 +299,12 @@ LCID MSVCRT_locale_to_LCID(const char *locale, unsigned short *codepage)
if (codepage)
*codepage = atoi(search.found_codepage);
if (strlen(locale) < sizeof(data->cached_locale)) {
strcpy(data->cached_locale, locale);
data->cached_lcid = lcid;
data->cached_cp = codepage ? *codepage : atoi(search.found_codepage);
}
return lcid;
}
......
......@@ -237,7 +237,12 @@ struct __thread_data {
void *unk6[3];
int unk7;
EXCEPTION_RECORD *exc_record;
void *unk8[100];
void *unk8[7];
LCID cached_lcid;
int unk9[3];
DWORD cached_cp;
char cached_locale[131];
void *unk10[100];
};
typedef struct __thread_data thread_data_t;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment