[前][次][番号順一覧][スレッド一覧]

ruby-changes:59284

From: Nobuyoshi <ko1@a...>
Date: Tue, 17 Dec 2019 11:05:04 +0900 (JST)
Subject: [ruby-changes:59284] ebe5b66ca8 (master): Reduce tzset calls

https://git.ruby-lang.org/ruby.git/commit/?id=ebe5b66ca8

From ebe5b66ca8e639468e14c4134a415403d949385e Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Tue, 17 Dec 2019 10:48:17 +0900
Subject: Reduce tzset calls

Set up-to-date flag always when calling tzset().

diff --git a/time.c b/time.c
index ef8a995..021421c 100644
--- a/time.c
+++ b/time.c
@@ -673,16 +673,21 @@ static VALUE tm_from_time(VALUE klass, VALUE time); https://github.com/ruby/ruby/blob/trunk/time.c#L673
 
 bool ruby_tz_uptodate_p;
 
+static void
+update_tz(void)
+{
+    if (ruby_tz_uptodate_p) return;
+    ruby_tz_uptodate_p = true;
+    tzset();
+}
+
 static struct tm *
 rb_localtime_r(const time_t *t, struct tm *result)
 {
 #if defined __APPLE__ && defined __LP64__
     if (*t != (time_t)(int)*t) return NULL;
 #endif
-    if (!ruby_tz_uptodate_p) {
-	ruby_tz_uptodate_p = true;
-	tzset();
-    }
+    update_tz();
 #ifdef HAVE_GMTIME_R
     result = localtime_r(t, result);
 #else
@@ -3140,9 +3145,7 @@ find_time_t(struct tm *tptr, int utc_p, time_t *tp) https://github.com/ruby/ruby/blob/trunk/time.c#L3145
     find_dst = 0 < tptr->tm_isdst;
 
     /* /etc/localtime might be changed. reload it. */
-    if (!ruby_tz_uptodate_p) {
-        tzset();
-    }
+    update_tz();
 
     tm0 = *tptr;
     if (tm0.tm_mon < 0) {
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]