diff options
| author | Jeremy Evans <code@jeremyevans.net> | 2024-05-11 12:12:52 -0700 |
|---|---|---|
| committer | Jeremy Evans <code@jeremyevans.net> | 2024-05-21 05:33:57 +0900 |
| commit | 2433b57b6a3a6f8e65f61c27d707e1c7f5407986 (patch) | |
| tree | 1c296abcc567a614be6e788ec575fbc2fd3e2e53 /test/ruby | |
| parent | f021bcdbbe69d324b36c03dab4d2347608658b86 (diff) | |
Avoid hash allocation for empty ruby2_keywords flagged keyword hash
If the method being called does not have a keyword splat parameter,
there is no point in allocating the hash, because the hash will
be unused (as empty keyword hashes are ignored).
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_allocation.rb | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/test/ruby/test_allocation.rb b/test/ruby/test_allocation.rb index 8f6858f1cf..ab3ae15a9f 100644 --- a/test/ruby/test_allocation.rb +++ b/test/ruby/test_allocation.rb @@ -100,7 +100,7 @@ class TestAllocation < Test::Unit::TestCase check_allocations(0, 1, "none(**empty_hash, **empty_hash#{block})") check_allocations(1, 1, "none(*empty_array, *empty_array, **empty_hash, **empty_hash#{block})") - check_allocations(#{block.empty?} ? 0 : 1, #{block.empty?} ? 0 : 1, "none(*r2k_empty_array#{block})") + check_allocations(#{block.empty?} ? 0 : 1, 0, "none(*r2k_empty_array#{block})") RUBY end @@ -120,7 +120,7 @@ class TestAllocation < Test::Unit::TestCase check_allocations(0, 1, "required(**hash1, **empty_hash#{block})") check_allocations(1, 0, "required(*array1, *empty_array, **empty_hash#{block})") - check_allocations(#{block.empty?} ? 0 : 1, #{block.empty?} ? 0 : 1, "required(*r2k_empty_array1#{block})") + check_allocations(#{block.empty?} ? 0 : 1, 0, "required(*r2k_empty_array1#{block})") check_allocations(0, 1, "required(*r2k_array#{block})") # Currently allocates 1 array unnecessarily due to splatarray true @@ -144,8 +144,8 @@ class TestAllocation < Test::Unit::TestCase check_allocations(0, 1, "optional(**hash1, **empty_hash#{block})") check_allocations(1, 0, "optional(*array1, *empty_array, **empty_hash#{block})") - check_allocations(#{block.empty?} ? 0 : 1, #{block.empty?} ? 0 : 1, "optional(*r2k_empty_array#{block})") - check_allocations(#{block.empty?} ? 0 : 1, #{block.empty?} ? 0 : 1, "optional(*r2k_empty_array1#{block})") + check_allocations(#{block.empty?} ? 0 : 1, 0, "optional(*r2k_empty_array#{block})") + check_allocations(#{block.empty?} ? 0 : 1, 0, "optional(*r2k_empty_array1#{block})") check_allocations(0, 1, "optional(*r2k_array#{block})") # Currently allocates 1 array unnecessarily due to splatarray true @@ -180,8 +180,8 @@ class TestAllocation < Test::Unit::TestCase check_allocations(1, 0, "splat(*array1, *empty_array, **empty_hash#{block})") check_allocations(1, 1, "splat(*empty_array, **hash1, **empty_hash#{block})") - check_allocations(1, 1, "splat(*r2k_empty_array#{block})") - check_allocations(1, 1, "splat(*r2k_empty_array1#{block})") + check_allocations(1, 0, "splat(*r2k_empty_array#{block})") + check_allocations(1, 0, "splat(*r2k_empty_array1#{block})") check_allocations(1, 1, "splat(*r2k_array#{block})") check_allocations(1, 1, "splat(*r2k_array1#{block})") RUBY @@ -214,7 +214,7 @@ class TestAllocation < Test::Unit::TestCase check_allocations(1, 0, "req_splat(*array1, *empty_array, **empty_hash#{block})") check_allocations(1, 1, "req_splat(*empty_array, **hash1, **empty_hash#{block})") - check_allocations(1, 1, "req_splat(*r2k_empty_array1#{block})") + check_allocations(1, 0, "req_splat(*r2k_empty_array1#{block})") check_allocations(1, 1, "req_splat(*r2k_array#{block})") check_allocations(1, 1, "req_splat(*r2k_array1#{block})") RUBY @@ -247,7 +247,7 @@ class TestAllocation < Test::Unit::TestCase check_allocations(1, 0, "splat_post(*array1, *empty_array, **empty_hash#{block})") check_allocations(1, 1, "splat_post(*empty_array, **hash1, **empty_hash#{block})") - check_allocations(1, 1, "splat_post(*r2k_empty_array1#{block})") + check_allocations(1, 0, "splat_post(*r2k_empty_array1#{block})") check_allocations(1, 1, "splat_post(*r2k_array#{block})") check_allocations(1, 1, "splat_post(*r2k_array1#{block})") RUBY @@ -277,7 +277,7 @@ class TestAllocation < Test::Unit::TestCase check_allocations(0, 1, "keyword(**hash1, **empty_hash#{block})") check_allocations(1, 0, "keyword(*empty_array, *empty_array, **empty_hash#{block})") - check_allocations(1, 1, "keyword(*r2k_empty_array#{block})") + check_allocations(1, 0, "keyword(*r2k_empty_array#{block})") check_allocations(1, 1, "keyword(*r2k_array#{block})") # Currently allocates 1 array unnecessarily due to splatarray true @@ -385,7 +385,7 @@ class TestAllocation < Test::Unit::TestCase check_allocations(1, 1, "required_and_keyword(*array1, *empty_array, a: 2, **empty_hash#{block})") check_allocations(1, 1, "required_and_keyword(*array1, *empty_array, **hash1, **empty_hash#{block})") - check_allocations(1, 1, "required_and_keyword(*r2k_empty_array1#{block})") + check_allocations(1, 0, "required_and_keyword(*r2k_empty_array1#{block})") check_allocations(1, 1, "required_and_keyword(*r2k_array1#{block})") # Currently allocates 1 array unnecessarily due to splatarray true @@ -436,9 +436,9 @@ class TestAllocation < Test::Unit::TestCase check_allocations(1, 1, "splat_and_keyword(*array1, **hash1, **empty_hash#{block})") check_allocations(1, 0, "splat_and_keyword(*array1, **nil#{block})") - check_allocations(1, 1, "splat_and_keyword(*r2k_empty_array#{block})") + check_allocations(1, 0, "splat_and_keyword(*r2k_empty_array#{block})") check_allocations(1, 1, "splat_and_keyword(*r2k_array#{block})") - check_allocations(1, 1, "splat_and_keyword(*r2k_empty_array1#{block})") + check_allocations(1, 0, "splat_and_keyword(*r2k_empty_array1#{block})") check_allocations(1, 1, "splat_and_keyword(*r2k_array1#{block})") RUBY end @@ -758,11 +758,11 @@ class TestAllocation < Test::Unit::TestCase check_allocations(1, 1, "r2k(*array1, **hash1, **empty_hash#{block})") check_allocations(1, 0, "r2k(*array1, **nil#{block})") - check_allocations(1, 1, "r2k(*r2k_empty_array#{block})") + check_allocations(1, 0, "r2k(*r2k_empty_array#{block})") check_allocations(1, 1, "r2k(*r2k_array#{block})") unless defined?(RubyVM::YJIT.enabled?) && RubyVM::YJIT.enabled? # YJIT may or may not allocate depending on arch? - check_allocations(1, 1, "r2k(*r2k_empty_array1#{block})") + check_allocations(1, 0, "r2k(*r2k_empty_array1#{block})") check_allocations(1, 1, "r2k(*r2k_array1#{block})") end RUBY |
