diff options
| author | Jeremy Evans <code@jeremyevans.net> | 2025-01-18 08:54:28 -0800 |
|---|---|---|
| committer | Jeremy Evans <code@jeremyevans.net> | 2025-03-27 13:59:03 -0700 |
| commit | 43683e1e9d8f7f6ed3fb4a48598190a0993f8f66 (patch) | |
| tree | 9bac68ee1b9a758d34ff854b063707fe89389521 /spec/ruby/core/basicobject/method_missing_spec.rb | |
| parent | 72cb68972c878ca9a221bfffc6b6757807f8b2cf (diff) | |
Avoid allocation for anonymous positional splat with no arguments
Anonymous positional splats cannot be directly accessed, they can
only be passed as splats to other methods. So if an anonymous
positional splat would be empty, you can use a shared frozen
empty array to save an allocation.
```ruby
def a(*) end
a()
```
This is similar to how anonymous empty keyword splats are optimized,
except those use `nil` instead of a shared empty frozen hash.
This updates the allocation tests to check that the array allocations
are avoided where possible.
It also makes a small change to test_iseq.rb to ensure an unfrozen
hash is passed as the value of an anonymous splat parameter.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/12596
Diffstat (limited to 'spec/ruby/core/basicobject/method_missing_spec.rb')
0 files changed, 0 insertions, 0 deletions
