diff --git a/yjit.rb b/yjit.rb index a9f260e4f4..632d1c58c3 100644 --- a/yjit.rb +++ b/yjit.rb @@ -437,11 +437,10 @@ module RubyVM::YJIT # Format large numbers with comma separators for readability def format_number(pad, number) - integer, decimal = number.to_s.split(".") - d_groups = integer.chars.reverse.each_slice(3) - with_commas = d_groups.map(&:join).join(',').reverse - formatted = [with_commas, decimal].compact.join(".") - formatted.rjust(pad, ' ') + s = number.to_s + i = s.index('.') || s.size + s.insert(i -= 3, ',') while i > 3 + s.rjust(pad, ' ') end # Format a number along with a percentage over a total value