Skip to content

Commit 0251642

Browse files
committed
Inline rb_to_float in its only usage
1 parent f01718d commit 0251642

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/main/ruby/core/type.rb

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,12 @@ def self.rb_big2ulong(val)
200200
end
201201

202202
def self.rb_to_f(val)
203-
rb_to_float(val, :to_f);
203+
return val if object_kind_of?(val, Float)
204+
res = convert_type(val, Float, :to_f, true)
205+
unless object_kind_of?(res, Float)
206+
conversion_mismatch(val, Float, :to_f, res)
207+
end
208+
res
204209
end
205210

206211
def self.rb_to_int(val)
@@ -212,15 +217,6 @@ def self.rb_to_int(val)
212217
res
213218
end
214219

215-
def self.rb_to_float(val, meth)
216-
return val if object_kind_of?(val, Float)
217-
res = convert_type(val, Float, meth, true)
218-
unless object_kind_of?(res, Float)
219-
conversion_mismatch(val, Float, meth, res)
220-
end
221-
res
222-
end
223-
224220
def self.conversion_mismatch(val, cls, meth, res)
225221
raise TypeError, "can't convert #{object_class(val)} to #{cls} (#{object_class(val)}##{meth} gives #{object_class(res)})"
226222
end

0 commit comments

Comments
 (0)