Skip to content

Commit fe362be

Browse files
ZJIT: Avoid mutating string in zjit stats (ruby#14485)
[ZJIT] Avoid mutating string in zjit stats GitHub runs with a Symbol patch that causes a frozen string error when running `--zjit-stats` ```rb Class Symbol alias_method :to_s, :name end ``` I remember hearing that Shopify runs a similar patch, and that we might try to make this the default behavior in Ruby some day. Any chance we can avoid mutating the string here in case it's frozen? That does mean we'll end up making some extra strings when it's not frozen, but I think that's OK for printing stats.
1 parent ce94add commit fe362be

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

zjit.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def print_counters_with_prefix(buf:, stats:, prefix:, prompt:, limit: nil)
101101
counters = stats.select { |key, value| key.start_with?(prefix) && value > 0 }
102102
return if stats.empty?
103103

104-
counters.transform_keys! { |key| key.to_s.delete_prefix!(prefix) }
104+
counters.transform_keys! { |key| key.to_s.delete_prefix(prefix) }
105105
left_pad = counters.keys.map(&:size).max
106106
right_pad = counters.values.map { |value| number_with_delimiter(value).size }.max
107107
total = counters.values.sum

0 commit comments

Comments
 (0)