From e9eec98d5c74fb816ee4615d437aefb0d336de92 Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Wed, 24 Jun 2015 15:13:07 +0200 Subject: [PATCH] msvcrt: Cache locale string to LCID conversion results. --- dlls/msvcrt/locale.c | 13 +++++++++++++ dlls/msvcrt/msvcrt.h | 7 ++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/dlls/msvcrt/locale.c b/dlls/msvcrt/locale.c index bd919e6a2ea..ad06b1ae8ad 100644 --- a/dlls/msvcrt/locale.c +++ b/dlls/msvcrt/locale.c @@ -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; } diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h index d85c9ec657d..19f3c1060c2 100644 --- a/dlls/msvcrt/msvcrt.h +++ b/dlls/msvcrt/msvcrt.h @@ -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;