Piotr Caban : msvcrt: Cache locale string to LCID conversion results.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Jun 24 09:51:06 CDT 2015
Module: wine
Branch: master
Commit: e9eec98d5c74fb816ee4615d437aefb0d336de92
URL: http://source.winehq.org/git/wine.git/?a=commit;h=e9eec98d5c74fb816ee4615d437aefb0d336de92
Author: Piotr Caban <piotr at codeweavers.com>
Date: Wed Jun 24 15:13:07 2015 +0200
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 bd919e6..ad06b1a 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 d85c9ec..19f3c10 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;
More information about the wine-cvs
mailing list