[glib/wip/antoniof/fallback-timezone-cache-lookup: 3/3] gtimezone: Also lookup fallback ids in the cached timezones
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/antoniof/fallback-timezone-cache-lookup: 3/3] gtimezone: Also lookup fallback ids in the cached timezones
- Date: Wed, 23 Sep 2020 18:23:28 +0000 (UTC)
commit 9a1cf4f925a39a66eeebbd7b9d2959b8651f9fbf
Author: António Fernandes <antoniof gnome org>
Date: Wed Sep 23 19:03:03 2020 +0100
gtimezone: Also lookup fallback ids in the cached timezones
We cache GTimeZone instances to avoid expensive construction when the
same id is requested again.
However, if no id is passed, we always construct a new instance for the
default/fallback timezone, even if later doesn't change.
With the recent introduction of some heavy calculations [1], repeated
instance construction in such cases has visible performance impact in
nautilus list view and other such GtkTreeView consumers.
Now that we get the resolved_identifier ealier, we can account for the
default/fallback timezone when looking up for existing instances in the
cache.
Fixes: https://gitlab.gnome.org/GNOME/glib/-/issues/2204
Based on idea proposed by Sebastian Keller <skeller gnome org>
[1] 25d950b61f92f25cc9ab20d683aa4d6969f93098
glib/gtimezone.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/glib/gtimezone.c b/glib/gtimezone.c
index 42a73bd27..103256f72 100644
--- a/glib/gtimezone.c
+++ b/glib/gtimezone.c
@@ -1673,9 +1673,9 @@ g_time_zone_new (const gchar *identifier)
#endif
}
- if (identifier)
+ if (resolved_identifier)
{
- tz = g_hash_table_lookup (time_zones, identifier);
+ tz = g_hash_table_lookup (time_zones, resolved_identifier);
if (tz)
{
g_atomic_int_inc (&tz->ref_count);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]