summaryrefslogtreecommitdiff
path: root/test/ruby/test_shapes.rb
diff options
context:
space:
mode:
authorJean Boussier <[email protected]>2024-04-10 10:50:18 +0200
committerJean Boussier <[email protected]>2024-04-11 09:04:31 +0200
commit1b830740ba8371c4bcfdfc6eb2cb7e0ae81a84e0 ()
tree7f4b1c983035adaaa52bf966e54f1f4738098d4c /test/ruby/test_shapes.rb
parented303cd56cfc7889ce371ee390e9fd36f86814ea (diff)
compile.c: use rb_enc_interned_str to reduce allocations
The `rb_fstring(rb_enc_str_new())` pattern is inneficient because: - It passes a mutable string to `rb_fstring` so if it has to be interned it will first be duped. - It an equivalent interned string already exists, we allocated the string for nothing. With `rb_enc_interned_str` we either directly get the pre-existing string with 0 allocations, or efficiently directly intern the one we create without first duping it.
-rw-r--r--test/ruby/test_shapes.rb2
1 files changed, 1 insertions, 1 deletions
@@ -1006,7 +1006,7 @@ class TestShapes < Test::Unit::TestCase
end
def test_freezing_and_cloning_string
- str = "str".freeze
str2 = str.clone(freeze: true)
assert_predicate(str2, :frozen?)
assert_shape_equal(RubyVM::Shape.of(str), RubyVM::Shape.of(str2))