Skip to content

Commit 20a6d3f

Browse files
authored
Merge pull request #2014 from ericproulx/reduced_retained_array
Reduced array allocation
2 parents 600eee9 + 3e5a953 commit 20a6d3f

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
### 1.3.2 (Next)
22

33
#### Features
4-
4+
* Your contribution here.
5+
* [#2014](https://github.com/ruby-grape/grape/pull/2014): Reduce total allocated arrays - [@ericproulx](https://github.com/ericproulx).
56
* [#2011](https://github.com/ruby-grape/grape/pull/2011): Reduce total retained regexes - [@ericproulx](https://github.com/ericproulx).
67

78
#### Fixes

lib/grape/util/reverse_stackable_values.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ class ReverseStackableValues < StackableValues
88
protected
99

1010
def concat_values(inherited_value, new_value)
11+
return inherited_value unless new_value
12+
1113
[].tap do |value|
12-
value.concat(new_value) if new_value
14+
value.concat(new_value)
1315
value.concat(inherited_value)
1416
end
1517
end

lib/grape/util/stackable_values.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ def to_hash
2929
protected
3030

3131
def concat_values(inherited_value, new_value)
32+
return inherited_value unless new_value
33+
3234
[].tap do |value|
3335
value.concat(inherited_value)
34-
value.concat(new_value) if new_value
36+
value.concat(new_value)
3537
end
3638
end
3739
end

0 commit comments

Comments
 (0)