diff options
| author | Jeremy Evans <code@jeremyevans.net> | 2022-07-20 14:06:28 -0700 |
|---|---|---|
| committer | Jeremy Evans <code@jeremyevans.net> | 2022-08-09 22:19:46 -0700 |
| commit | fc4b4f2e8db3d68b80b9c7580c40a0165736006c (patch) | |
| tree | 7004516463d341a5cb5795e43eaf4a0894d57d5c /include/ruby/assert.h | |
| parent | 7922fd65e30fb9f011b939dead38cda94a7e2721 (diff) | |
Expand newarray/expandarray optimization for unequal operands
This optimizes unbalanced multiple assignment cases such as:
```ruby
a.b, c.d = e, f, g
a.b, c.d, e.f = g, h
```
Previously, this would use:
```
newarray(3)
expandarray(2, 0)
newarray(2)
expandarray(3, 0)
```
These would both allocate arrays. This switches to opt_reverse
with either pop or putnil:
```
pop
opt_reverse(2)
putnil
opt_reverse(3)
```
This avoids an unnecessary array allocation, and results in a 35-76%
performance increase in these types of unbalanced cases (tested with
benchmark/masgn.yml).
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6158
Diffstat (limited to 'include/ruby/assert.h')
0 files changed, 0 insertions, 0 deletions
