kernelbase: Improve Get{, Dynamic}TimeZoneInformation() performance.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49808 Signed-off-by: Akihiro Sagawa <sagawa.aki@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
d6da10f3fb
commit
d5edadf35a
|
@ -4122,6 +4122,20 @@ INT WINAPI DECLSPEC_HOTPATCH GetCalendarInfoEx( const WCHAR *locale, CALID calen
|
||||||
return GetCalendarInfoW( lcid, calendar, type, data, count, value );
|
return GetCalendarInfoW( lcid, calendar, type, data, count, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static CRITICAL_SECTION tzname_section;
|
||||||
|
static CRITICAL_SECTION_DEBUG tzname_section_debug =
|
||||||
|
{
|
||||||
|
0, 0, &locale_section,
|
||||||
|
{ &tzname_section_debug.ProcessLocksList, &tzname_section_debug.ProcessLocksList },
|
||||||
|
0, 0, { (DWORD_PTR)(__FILE__ ": tzname_section") }
|
||||||
|
};
|
||||||
|
static CRITICAL_SECTION tzname_section = { &tzname_section_debug, -1, 0, 0, 0, 0 };
|
||||||
|
static struct {
|
||||||
|
LCID lcid;
|
||||||
|
WCHAR key_name[128];
|
||||||
|
WCHAR standard_name[32];
|
||||||
|
WCHAR daylight_name[32];
|
||||||
|
} cached_tzname;
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* GetDynamicTimeZoneInformation (kernelbase.@)
|
* GetDynamicTimeZoneInformation (kernelbase.@)
|
||||||
|
@ -4134,15 +4148,34 @@ DWORD WINAPI DECLSPEC_HOTPATCH GetDynamicTimeZoneInformation( DYNAMIC_TIME_ZONE_
|
||||||
if (!set_ntstatus( RtlQueryDynamicTimeZoneInformation( (RTL_DYNAMIC_TIME_ZONE_INFORMATION *)info )))
|
if (!set_ntstatus( RtlQueryDynamicTimeZoneInformation( (RTL_DYNAMIC_TIME_ZONE_INFORMATION *)info )))
|
||||||
return TIME_ZONE_ID_INVALID;
|
return TIME_ZONE_ID_INVALID;
|
||||||
|
|
||||||
if (!RegOpenKeyExW( tz_key, info->TimeZoneKeyName, 0, KEY_ALL_ACCESS, &key ))
|
RtlEnterCriticalSection( &tzname_section );
|
||||||
|
if (cached_tzname.lcid == GetThreadLocale() &&
|
||||||
|
!wcscmp( info->TimeZoneKeyName, cached_tzname.key_name ))
|
||||||
{
|
{
|
||||||
RegLoadMUIStringW( key, L"MUI_Std", info->StandardName,
|
wcscpy( info->StandardName, cached_tzname.standard_name );
|
||||||
sizeof(info->StandardName), NULL, 0, system_dir );
|
wcscpy( info->DaylightName, cached_tzname.daylight_name );
|
||||||
RegLoadMUIStringW( key, L"MUI_Dlt", info->DaylightName,
|
RtlLeaveCriticalSection( &tzname_section );
|
||||||
sizeof(info->DaylightName), NULL, 0, system_dir );
|
}
|
||||||
RegCloseKey( key );
|
else
|
||||||
|
{
|
||||||
|
RtlLeaveCriticalSection( &tzname_section );
|
||||||
|
if (!RegOpenKeyExW( tz_key, info->TimeZoneKeyName, 0, KEY_ALL_ACCESS, &key ))
|
||||||
|
{
|
||||||
|
RegLoadMUIStringW( key, L"MUI_Std", info->StandardName,
|
||||||
|
sizeof(info->StandardName), NULL, 0, system_dir );
|
||||||
|
RegLoadMUIStringW( key, L"MUI_Dlt", info->DaylightName,
|
||||||
|
sizeof(info->DaylightName), NULL, 0, system_dir );
|
||||||
|
RegCloseKey( key );
|
||||||
|
}
|
||||||
|
else return TIME_ZONE_ID_INVALID;
|
||||||
|
|
||||||
|
RtlEnterCriticalSection( &tzname_section );
|
||||||
|
cached_tzname.lcid = GetThreadLocale();
|
||||||
|
wcscpy( cached_tzname.key_name, info->TimeZoneKeyName );
|
||||||
|
wcscpy( cached_tzname.standard_name, info->StandardName );
|
||||||
|
wcscpy( cached_tzname.daylight_name, info->DaylightName );
|
||||||
|
RtlLeaveCriticalSection( &tzname_section );
|
||||||
}
|
}
|
||||||
else return TIME_ZONE_ID_INVALID;
|
|
||||||
|
|
||||||
NtQuerySystemTime( &now );
|
NtQuerySystemTime( &now );
|
||||||
return get_timezone_id( (TIME_ZONE_INFORMATION *)info, now, FALSE );
|
return get_timezone_id( (TIME_ZONE_INFORMATION *)info, now, FALSE );
|
||||||
|
|
Loading…
Reference in New Issue