mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
f8dbff557a
commit
4c875b6e66
1 changed files with 3 additions and 1 deletions
4
time.c
4
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue