# HG changeset patch # User Richard Laager # Date 1141068690 0 # Node ID 0f708ed029020d0a7dd7202d53d2cfa76baa98ea # Parent d4af79bc2d0a467237a0ca405d6c9c7199143ad9 [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 diff -r d4af79bc2d0a -r 0f708ed02902 src/win32/libc_interface.c --- 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 ""; } +