Mercurial > pidgin
changeset 13338:0f708ed02902
[gaim-migrate @ 15708]
Daniel and I figured it would be a good idea to cache the results of the registry lookup. For the kind of code using gaim_utf8_strftime() right now, this gets us down to one registry search per Gaim instance on localized versions of Windows (zero on English versions).
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Mon, 27 Feb 2006 19:31:30 +0000 |
parents | d4af79bc2d0a |
children | d46a27d29eed |
files | src/win32/libc_interface.c |
diffstat | 1 files changed, 20 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/win32/libc_interface.c Mon Feb 27 17:30:15 2006 +0000 +++ b/src/win32/libc_interface.c Mon Feb 27 19:31:30 2006 +0000 @@ -464,6 +464,10 @@ const char *udst; /* Unix name of daylight timezone */ } win32_tzmap[] = { + { + "", "", + "", "", + }, /* * This list was built from the contents of the registry at * "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones" @@ -924,12 +928,27 @@ { gaim_debug_info("wgaim", "TZ \"%s\" matches localized Windows timezone \"%s\" (\"%s\")", win32_tzmap[i].ustd, tzname, localtzname); + + /* Cache the Result */ + if (win32_tzmap[0].wstd[0] != '\0') + g_free(win32_tzmap[0].wstd); + win32_tzmap[0].wstd = g_strdup(tzname); + win32_tzmap[1].ustd = win32_tzmap[i].ustd; + return win32_tzmap[i].ustd; } if (strcmp(localtzname, win32_tzmap[i].wdst) == 0) { gaim_debug_info("wgaim", "TZ \"%s\" matches localized Windows timezone \"%s\" (\"%s\")", win32_tzmap[i].udst, tzname, localtzname); + + /* Cache the Result */ + if (win32_tzmap[0].wdst[0] != '\0') + g_free(win32_tzmap[0].wdst); + + win32_tzmap[0].wdst = g_strdup(tzname); + win32_tzmap[1].udst = win32_tzmap[i].udst; + return win32_tzmap[i].udst; } } @@ -938,3 +957,4 @@ gaim_debug_warning("wgaim", "could not find a match for Windows timezone \"%s\"", tzname); return ""; } +