summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Kokubun <takashi.kokubun@shopify.com>2025-09-30 10:50:33 -0700
committerGitHub <noreply@github.com>2025-09-30 10:50:33 -0700
commit83f1082e638e6f9161c4ddd0acad7a658ce4648b (patch)
tree78319e4f9823fb3f917eb78842b370da3509838e
parent4ae5d69d1fca828ec1a50fab0126d88fc0a3f361 (diff)
ZJIT: Fix "malformed format string" on stats (#14681)
-rw-r--r--zjit.rb8
1 files changed, 3 insertions, 5 deletions
diff --git a/zjit.rb b/zjit.rb
index 8289846c03..83f8adb866 100644
--- a/zjit.rb
+++ b/zjit.rb
@@ -221,8 +221,8 @@ class << RubyVM::ZJIT
return if stats.empty?
counters.transform_keys! { |key| key.to_s.delete_prefix(prefix) }
- left_pad = counters.keys.map(&:size).max
- right_pad = counters.values.map { |value| number_with_delimiter(value).size }.max
+ key_pad = counters.keys.map(&:size).max
+ value_pad = counters.values.map { |value| number_with_delimiter(value).size }.max
total = counters.values.sum
counters = counters.to_a
@@ -234,9 +234,7 @@ class << RubyVM::ZJIT
buf << " (%.1f%% of total #{number_with_delimiter(total)})" % (100.0 * counters.map(&:last).sum / total) if limit
buf << ":\n"
counters.each do |key, value|
- padded_key = key.rjust(left_pad, ' ')
- padded_value = number_with_delimiter(value).rjust(right_pad, ' ')
- buf << " #{padded_key}: #{padded_value} (%4.1f%%)\n" % (100.0 * value / total)
+ buf << " %*s: %*s (%4.1f%%)\n" % [key_pad, key, value_pad, number_with_delimiter(value), (100.0 * value / total)]
end
end