Michael Karcher : oleaut32: Cache localised number chars.
Module: wine Branch: master Commit: abaac300d13e8e9e93f937a22f7eba9fffd154b7 URL: http://source.winehq.org/git/wine.git/?a=commit;h=abaac300d13e8e9e93f937a22f... Author: Michael Karcher <wine(a)mkarcher.dialup.fu-berlin.de> Date: Thu May 15 00:13:55 2008 +0200 oleaut32: Cache localised number chars. --- dlls/oleaut32/variant.c | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diff --git a/dlls/oleaut32/variant.c b/dlls/oleaut32/variant.c index 4eecfce..e6191d1 100644 --- a/dlls/oleaut32/variant.c +++ b/dlls/oleaut32/variant.c @@ -1468,9 +1468,25 @@ HRESULT WINAPI VarUdateFromDate(DATE dateIn, ULONG dwFlags, UDATE *lpUdate) static void VARIANT_GetLocalisedNumberChars(VARIANT_NUMBER_CHARS *lpChars, LCID lcid, DWORD dwFlags) { static const VARIANT_NUMBER_CHARS defaultChars = { '-','+','.',',','$',0,'.',',' }; + static CRITICAL_SECTION csLastChars = { NULL, -1, 0, 0, 0, 0 }; + static VARIANT_NUMBER_CHARS lastChars; + static LCID lastLcid = -1; + static DWORD lastFlags = 0; LCTYPE lctype = dwFlags & LOCALE_NOUSEROVERRIDE; WCHAR buff[4]; + /* To make caching thread-safe, a critical section is needed */ + EnterCriticalSection(&csLastChars); + + /* Asking for default locale entries is very expensive: It is a registry + server call. So cache one locally, as Microsoft does it too */ + if(lcid == lastLcid && dwFlags == lastFlags) + { + memcpy(lpChars, &lastChars, sizeof(defaultChars)); + LeaveCriticalSection(&csLastChars); + return; + } + memcpy(lpChars, &defaultChars, sizeof(defaultChars)); GET_NUMBER_TEXT(LOCALE_SNEGATIVESIGN, cNegativeSymbol); GET_NUMBER_TEXT(LOCALE_SPOSITIVESIGN, cPositiveSymbol); @@ -1490,6 +1506,11 @@ static void VARIANT_GetLocalisedNumberChars(VARIANT_NUMBER_CHARS *lpChars, LCID } TRACE("lcid 0x%x, cCurrencyLocal =%d,%d '%c','%c'\n", lcid, lpChars->cCurrencyLocal, lpChars->cCurrencyLocal2, lpChars->cCurrencyLocal, lpChars->cCurrencyLocal2); + + memcpy(&lastChars, lpChars, sizeof(defaultChars)); + lastLcid = lcid; + lastFlags = dwFlags; + LeaveCriticalSection(&csLastChars); } /* Number Parsing States */
participants (1)
-
Alexandre Julliard