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:
parent
cb69c19e8a
commit
05a3dc1a65
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
|
@ -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
|
||||
|
|
6
object.c
6
object.c
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue