* time.c (tm_initialize): allow 7th argument as well as
Time#initialize, but just ignore.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65420 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* 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
* time.c (tm_initialize): arguments other than year are optional
now as Time.new.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65296 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
The former states explicitly that the argument must be a literal,
and can optimize away `strlen` on all compilers.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* time.c (zone_str): while rb_fstring_usascii and the family
require that the argument string is never modified, tzname may
point areas which will be discarded by calling tzset().
make a String then call rb_fstring to copy the zone name.
when an ID equals TZ environment variable, its name string also
has modified by changing tzname.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* time.c (time_utc_or_local): split into time_s_mkutc and
time_s_mktime without utc flag.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* time.c (rb_localtime_r): call tzset() only after TZ environment
variable is changed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Both timegmw and gmtimew ignores leap second if the timezone doesn't
have leap seconds on the first call of init_leap_second_info()
* Add Bug::Time.reset_leap_second_info for testing
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63857 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Time.utc uses timegmw() and it uses leap second information.
If the given time is larger than known_leap_seconds_limit, it calls
find_time_t, which uses localtime(3) and calls stat(2) in it.
This patch avoid it by setting known_leap_seconds_limit to 0 if the timezone doesn't have leapsecond information (if no leap second is found "now", I assume the timezone doesn't have leapsecond information).
Before:
% time ./miniruby --disable-gem -e'time = Time.now; year = time.year; month = time.month; day = time.day; hour = time.hour; min = time.min; sec = time.sec + time.subsec; i = 0; while i < 100000; ::Time.utc(year, month, day, hour, min, sec); i += 1; end'
./miniruby --disable-gem 0.35s user 0.19s system 99% cpu 0.542 total
After:
% time ./miniruby --disable-gem -e'time = Time.now; year = time.year; month = time.month; day = time.day; hour = time.hour; min = time.min; sec = time.sec + time.subsec; i = 0; while i < 100000; ::Time.utc(year, month, day, hour, min, sec); i += 1; end'
./miniruby --disable-gem 0.23s user 0.00s system 99% cpu 0.233 total
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* time.c: state that Time#localtime does nothing when nothing
changes. [ruby-core:87675] [Bug #14880]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
No need to waste space on "to_r" and "to_int" which are
predefined in defs/id.def
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
compat_common_month_table and compat_leap_month_table should
not be writable.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
To be precise C90 says "A bit-field may have type int, unsigned
int, or signed int". It is clear that char or enum are NG.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61554 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* time.c (wadd): use internal addv() function to calculate internal value in
Time object. On 64-bit machine, Time object might have Fixnum object
internally by default and addv() can calculate Fixnum objects directly.
* time.c (wsub): use internal subv() function due the same reason in above.
Time#+ & Time#- will be faster around 15%.
[ruby-dev:50036] [Bug #13357] [Fix GH-1547]
### Before
user system total real
Time#+ 0.820000 0.000000 0.820000 ( 0.818081)
Time#- 0.810000 0.000000 0.810000 ( 0.813835)
### After
user system total real
Time#+ 0.710000 0.000000 0.710000 ( 0.710241)
Time#- 0.710000 0.010000 0.720000 ( 0.714151)
### Test code
require 'benchmark'
Benchmark.bmbm do |x|
x.report "Time#+" do
t = Time.now
2000000.times do
t + 1
end
end
x.report "Time#-" do
t = Time.now
2000000.times do
t - 1
end
end
end
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* time.c (wcmp): use internal cmp() function for comparing internal Fixnum value
in Time objects. On 64-bit machine, Time object might have Fixnum object
internally by default and cmp() can compare the Fixnum objects directly.
Time#<=> will be faster around 60% on 64-bit machine.
* time.c (cmp): add optimized path for comparing internal Bignum value by using
rb_big_cmp() API. On 32-bit machine, Time object might have Bignum object
internally by default.
Time#<=> will be faster around 50% on 32-bit machine.
[ruby-dev:50034] [Bug #13354] [Fix GH-1546]
### Before
user system total real
Fixnum 1.410000 0.000000 1.410000 ( 1.407848)
Bignum 1.550000 0.000000 1.550000 ( 1.549145)
### After
user system total real
Fixnum 0.880000 0.000000 0.880000 ( 0.886662)
Bignum 1.050000 0.000000 1.050000 ( 1.047994)
### Test code
require 'benchmark'
Benchmark.bmbm do |x|
x.report "Fixnum" do
t1 = Time.now
t2 = Time.now
10000000.times do
t1 <=> t2
end
end
x.report "Bignum" do
t1 = Time.at(2 ** 64)
t2 = Time.at(2 ** 64 + 1)
10000000.times do
t1 <=> t2
end
end
end
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
clang 4.0.0 emitted a warning: "taking address of packed member
'subsecx' of class or structure 'vtm' may result in an unaligned
pointer value [-Waddress-of-packed-member]".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* time.c (divv): add suffix to get rid of the name in C standard
library, and others together.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58312 b2dd03c8-39d4-4d8f-98ff-823fe69b080e