summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Colson <danieljamescolson@gmail.com>2025-09-09 11:55:00 -0400
committerGitHub <noreply@github.com>2025-09-09 08:55:00 -0700
commitfe362beb899a2b1a3d9012a4ad17b3c48d16b338 (patch)
treec3d6c1c4794ffce5e843e383bf9a7706351b6f56
parentce94add7fbef17cbfa10de6a5554455542e1081c (diff)
ZJIT: Avoid mutating string in zjit stats (#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.
-rw-r--r--zjit.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/zjit.rb b/zjit.rb
index 39b0e5eb22..5e647bfbee 100644
--- a/zjit.rb
+++ b/zjit.rb
@@ -101,7 +101,7 @@ class << RubyVM::ZJIT
counters = stats.select { |key, value| key.start_with?(prefix) && value > 0 }
return if stats.empty?
- counters.transform_keys! { |key| key.to_s.delete_prefix!(prefix) }
+ 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
total = counters.values.sum