1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Improve performance Kernel#Float with using Primitive.mandatory_only? method [Feature #18344] (#5133)

This commit is contained in:
S.H 2021-11-18 13:26:40 +09:00 committed by GitHub
parent cb69c19e8a
commit 05a3dc1a65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: git 2021-11-18 13:27:13 +09:00
Merged-By: k0kubun <takashikkbn@gmail.com>
2 changed files with 11 additions and 1 deletions

View file

@ -169,6 +169,10 @@ module Kernel
# Float("123.0_badstring", exception: false) #=> nil
#
def Float(arg, exception: true)
Primitive.rb_f_float(arg, exception)
if Primitive.mandatory_only?
Primitive.rb_f_float1(arg)
else
Primitive.rb_f_float(arg, exception)
end
end
end

View file

@ -3531,6 +3531,12 @@ rb_Float(VALUE val)
return rb_convert_to_float(val, TRUE);
}
static VALUE
rb_f_float1(rb_execution_context_t *ec, VALUE obj, VALUE arg)
{
return rb_convert_to_float(arg, TRUE);
}
static VALUE
rb_f_float(rb_execution_context_t *ec, VALUE obj, VALUE arg, VALUE opts)
{