Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling to_proc is faster than argumentless method #3497

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions core/app/models/spree/order_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,12 @@ def update_totals
end

def update_shipment_amounts
shipments.each do |shipment|
shipment.update_amounts
end
shipments.each(&:update_amounts)
end

# give each of the shipments a chance to update themselves
def update_shipments
shipments.each do |shipment|
shipment.update_state
end
shipments.each(&:update_state)
end

def update_payment_total
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
if reimbursement.return_items.empty?
reimbursement.return_items = reimbursement.customer_return.return_items
end
reimbursement.total = reimbursement.return_items.map { |ri| ri.amount }.sum
reimbursement.total = reimbursement.return_items.sum(&:amount)
end
end
end
2 changes: 1 addition & 1 deletion core/lib/spree/testing_support/shared_examples/gallery.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
include_context 'has multiple images'

it 'has the associated images' do
expect(subject.map { |picture| picture.id }).
expect(subject.map(&:id)).
to match_array([first_image.id, second_image.id])
end
end
Expand Down
2 changes: 1 addition & 1 deletion core/spec/models/spree/stock/simple_coordinator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ module Stock
shared_examples "a fulfillable package" do
it "packages correctly" do
expect(shipments).not_to be_empty
inventory_units = shipments.flat_map { |shipment| shipment.inventory_units }
inventory_units = shipments.flat_map(&:inventory_units)
expect(inventory_units.size).to eq(5)
expect(inventory_units.uniq.size).to eq(5)
end
Expand Down
2 changes: 1 addition & 1 deletion core/spec/models/spree/taxon_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
it 'returns all descendant variants' do
variants = taxon.all_variants
expect(variants.count).to eq(9)
expect(variants).to match_array([product1, product2, product3].flat_map{ |p| p.variants_including_master })
expect(variants).to match_array([product1, product2, product3].flat_map(&:variants_including_master))
end
end
end
Expand Down