[glib/wip/antoniof/fallback-timezone-cache-lookup: 2/2] 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: 2/2] gtimezone: Also lookup fallback ids in the cached timezones
- Date: Wed, 23 Sep 2020 18:30:49 +0000 (UTC)
commit afb682120db9dfd755411e8488ae3c71b89d41ba
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 b382872a0..ef02344b8 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]