summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntónio Fernandes <antoniof@gnome.org>2020-09-23 19:36:49 +0100
committerPhilip Withnall <pwithnall@endlessos.org>2020-10-15 14:43:46 +0100
commit36e7b48ad519c18ef3b4e1b4825b68088bd99dd9 (patch)
tree3e2490ad1ed9c6f5b4ab7108f2ad63efa10170c8
parent25e634b26b0238f10ae16427fd1453b5c9f23439 (diff)
downloadglib-36e7b48ad519c18ef3b4e1b4825b68088bd99dd9.tar.gz
Revert "gtimezone: Cache timezones based on the identifier they were created by"
This reverts commit 851241f19a3fd9ec693b3dd8f37a84c7f970984a. That commit avoids a performance regression but introduces a behavior regression: changes to /etc/localtime have no effect for the remaining of the application's runtime. With the optimization introduced by the previous commit, we can pass NULL to g_time_zone_new() repeatedly with no performance drawback, so we no longer have to workaround this case. Fixes: #2224
-rw-r--r--glib/gtimezone.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/glib/gtimezone.c b/glib/gtimezone.c
index ff9972502..3c555dbc7 100644
--- a/glib/gtimezone.c
+++ b/glib/gtimezone.c
@@ -198,7 +198,6 @@ static GHashTable/*<string?, GTimeZone>*/ *time_zones;
G_LOCK_DEFINE_STATIC (tz_default);
static GTimeZone *tz_default = NULL;
G_LOCK_DEFINE_STATIC (tz_local);
-static gchar *tzenv_cached = NULL;
static GTimeZone *tz_local = NULL;
#define MIN_TZYEAR 1916 /* Daylight Savings started in WWI */
@@ -1869,17 +1868,11 @@ g_time_zone_new_local (void)
G_LOCK (tz_local);
/* Is time zone changed and must be flushed? */
- if (tz_local && g_strcmp0 (tzenv, tzenv_cached) != 0)
- {
- g_clear_pointer (&tz_local, g_time_zone_unref);
- g_clear_pointer (&tzenv_cached, g_free);
- }
+ if (tz_local && g_strcmp0 (g_time_zone_get_identifier (tz_local), tzenv))
+ g_clear_pointer (&tz_local, g_time_zone_unref);
if (tz_local == NULL)
- {
- tz_local = g_time_zone_new (tzenv);
- tzenv_cached = g_strdup (tzenv);
- }
+ tz_local = g_time_zone_new (tzenv);
tz = g_time_zone_ref (tz_local);