summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-25 00:36:23 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-25 00:36:23 +0000
commit4c875b6e667d205fef5533670460e2043c9aaa6a (patch)
treeadef9ae4b9e70a966732467f8d3a2ce57d7dddbe
parentf8dbff557af75c0347f271cf5a1a557eea9f9eed (diff)
time.c: benchmark recovery
* time.c (time_localtime): check if `vtm.zone` is a simple zone name string before trying to call the conversion method. since r64952, `Time.getlocal` on UTC time has lost the performance about 45%, due to this call. the performance is about 90% of r64951 by avoiding it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--time.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/time.c b/time.c
index f801ee5ac1..dc4a8dbd4d 100644
--- a/time.c
+++ b/time.c
@@ -3623,6 +3623,7 @@ time_localtime(VALUE time)
{
struct time_object *tobj;
struct vtm vtm;
+ VALUE zone;
GetTimeval(time, tobj);
if (TZMODE_LOCALTIME_P(tobj)) {
@@ -3633,7 +3634,8 @@ time_localtime(VALUE time)
time_modify(time);
}
- if (!NIL_P(tobj->vtm.zone) && zone_localtime(tobj->vtm.zone, time)) {
+ zone = tobj->vtm.zone;
+ if (maybe_tzobj_p(zone) && zone_localtime(zone, time)) {
return time;
}