YJIT: skip to_a in format_number (#8815)
String#chars returns an array instead of an enumerator since Ruby 2.0.
This commit is contained in:
parent
909afcb4fc
commit
d3ea9070bb
2
yjit.rb
2
yjit.rb
@ -435,7 +435,7 @@ module RubyVM::YJIT
|
|||||||
# Format large numbers with comma separators for readability
|
# Format large numbers with comma separators for readability
|
||||||
def format_number(pad, number)
|
def format_number(pad, number)
|
||||||
integer, decimal = number.to_s.split(".")
|
integer, decimal = number.to_s.split(".")
|
||||||
d_groups = integer.chars.to_a.reverse.each_slice(3)
|
d_groups = integer.chars.reverse.each_slice(3)
|
||||||
with_commas = d_groups.map(&:join).join(',').reverse
|
with_commas = d_groups.map(&:join).join(',').reverse
|
||||||
formatted = [with_commas, decimal].compact.join(".")
|
formatted = [with_commas, decimal].compact.join(".")
|
||||||
formatted.rjust(pad, ' ')
|
formatted.rjust(pad, ' ')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user