Line 0
Link Here
|
|
|
1 |
--- glib/gtimezone.c.orig 2018-09-21 12:29:23.000000000 +0300 |
2 |
+++ glib/gtimezone.c 2019-09-12 00:53:42.760936000 +0300 |
3 |
@@ -187,6 +187,8 @@ |
4 |
|
5 |
G_LOCK_DEFINE_STATIC (time_zones); |
6 |
static GHashTable/*<string?, GTimeZone>*/ *time_zones; |
7 |
+static GTimeZone *tz_utc = NULL; |
8 |
+static GTimeZone *tz_local = NULL; |
9 |
|
10 |
#define MIN_TZYEAR 1916 /* Daylight Savings started in WWI */ |
11 |
#define MAX_TZYEAR 2999 /* And it's not likely ever to go away, but |
12 |
@@ -264,6 +266,8 @@ |
13 |
GTimeZone * |
14 |
g_time_zone_ref (GTimeZone *tz) |
15 |
{ |
16 |
+ if (tz == NULL) |
17 |
+ return NULL; |
18 |
g_assert (tz->ref_count > 0); |
19 |
|
20 |
g_atomic_int_inc (&tz->ref_count); |
21 |
@@ -1460,7 +1464,10 @@ |
22 |
GTimeZone * |
23 |
g_time_zone_new_utc (void) |
24 |
{ |
25 |
- return g_time_zone_new ("UTC"); |
26 |
+ if (tz_utc == NULL) { |
27 |
+ tz_utc = g_time_zone_new ("UTC"); |
28 |
+ } |
29 |
+ return g_time_zone_ref(tz_utc); |
30 |
} |
31 |
|
32 |
/** |
33 |
@@ -1483,7 +1490,10 @@ |
34 |
GTimeZone * |
35 |
g_time_zone_new_local (void) |
36 |
{ |
37 |
- return g_time_zone_new (getenv ("TZ")); |
38 |
+ if (tz_local == NULL) { |
39 |
+ tz_local = g_time_zone_new (getenv ("TZ")); |
40 |
+ } |
41 |
+ return g_time_zone_ref(tz_local); |
42 |
} |
43 |
|
44 |
#define TRANSITION(n) g_array_index (tz->transitions, Transition, n) |