Merge lp:~charlesk/indicator-datetime/lp-1238043 into lp:~indicator-applet-developers/indicator-datetime/trunk.13.10

Proposed by Charles Kerr
Status: Merged
Approved by: Ted Gould
Approved revision: 270
Merged at revision: 270
Proposed branch: lp:~charlesk/indicator-datetime/lp-1238043
Merge into: lp:~indicator-applet-developers/indicator-datetime/trunk.13.10
Diff against target: 70 lines (+29/-2)
1 file modified
src/service.c (+29/-2)
To merge this branch: bzr merge lp:~charlesk/indicator-datetime/lp-1238043
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Ted Gould (community) Approve
Review via email: mp+191097@code.launchpad.net

Description of the change

cache our internal GTimeZone instead of constantly re-creating it.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ted Gould (ted) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/service.c'
2--- src/service.c 2013-10-04 19:45:28 +0000
3+++ src/service.c 2013-10-15 14:30:40 +0000
4@@ -94,6 +94,9 @@
5 IndicatorDatetimeTimezone * tz_geoclue;
6 IndicatorDatetimePlanner * planner;
7
8+ /* cached GTimeZone for use by indicator_datetime_service_get_localtime() */
9+ GTimeZone * internal_timezone;
10+
11 guint own_id;
12 guint actions_export_id;
13 GDBusConnection * conn;
14@@ -376,6 +379,23 @@
15 g_date_time_unref (now);
16 }
17
18+static void
19+update_internal_timezone (IndicatorDatetimeService * self)
20+{
21+ priv_t * p = self->priv;
22+ const char * id;
23+
24+ /* find the id from tz_file or tz_geoclue if possible; NULL otherwise */
25+ id = NULL;
26+ if (!id && p->tz_file)
27+ id = indicator_datetime_timezone_get_timezone (p->tz_file);
28+ if (!id && p->tz_geoclue)
29+ id = indicator_datetime_timezone_get_timezone (p->tz_geoclue);
30+
31+ g_clear_pointer (&p->internal_timezone, g_time_zone_unref);
32+ p->internal_timezone = g_time_zone_new (id);
33+}
34+
35 /**
36 * General purpose handler for rebuilding sections and restarting their timers
37 * when time jumps for whatever reason:
38@@ -394,6 +414,7 @@
39 1. rebuild the necessary states / menuitems when time jumps
40 2. restart the timers so their new wait interval is correct */
41
42+ update_internal_timezone (self);
43 on_header_timer (self);
44 on_timezone_timer (self);
45 }
46@@ -1794,6 +1815,7 @@
47 for (i=0; i<N_PROFILES; ++i)
48 g_clear_object (&p->menus[i].menu);
49
50+ g_clear_pointer (&p->internal_timezone, g_time_zone_unref);
51 g_clear_object (&p->calendar_action);
52 g_clear_object (&p->desktop_header_action);
53 g_clear_object (&p->phone_header_action);
54@@ -1989,9 +2011,14 @@
55 /* This currently just returns the system time,
56 As we add test coverage, we'll need this to bypass the system time. */
57 GDateTime *
58-indicator_datetime_service_get_localtime (IndicatorDatetimeService * self G_GNUC_UNUSED)
59+indicator_datetime_service_get_localtime (IndicatorDatetimeService * self)
60 {
61- return g_date_time_new_now_local ();
62+ priv_t * p = self->priv;
63+
64+ if (G_UNLIKELY (p->internal_timezone == NULL))
65+ update_internal_timezone (self);
66+
67+ return g_date_time_new_now (p->internal_timezone);
68 }
69
70 void

Subscribers

People subscribed via source and target branches