ruby-changes:69800
From: S.H <ko1@a...>
Date: Thu, 18 Nov 2021 13:27:10 +0900 (JST)
Subject: [ruby-changes:69800] 05a3dc1a65 (master): Improve performance Kernel#Float with using Primitive.mandatory_only? method [Feature #18344] (#5133)
https://git.ruby-lang.org/ruby.git/commit/?id=05a3dc1a65 From 05a3dc1a654c5e92200d994d0a51a2e159c88162 Mon Sep 17 00:00:00 2001 From: "S.H" <gamelinks007@g...> Date: Thu, 18 Nov 2021 13:26:40 +0900 Subject: Improve performance Kernel#Float with using Primitive.mandatory_only? method [Feature #18344] (#5133) --- kernel.rb | 6 +++++- object.c | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/kernel.rb b/kernel.rb index de20fffcf91..9cc58bc1d96 100644 --- a/kernel.rb +++ b/kernel.rb @@ -169,6 +169,10 @@ module Kernel https://github.com/ruby/ruby/blob/trunk/kernel.rb#L169 # 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 diff --git a/object.c b/object.c index f98fb839366..755645b76e4 100644 --- a/object.c +++ b/object.c @@ -3531,6 +3531,12 @@ rb_Float(VALUE val) https://github.com/ruby/ruby/blob/trunk/object.c#L3531 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) { -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/