Skip to content

Commit

Permalink
Enumerable#reverse_each is faster than Enumerable#reverse.each
Browse files Browse the repository at this point in the history
  • Loading branch information
chessbyte committed Oct 16, 2019
1 parent b7c9523 commit 875742e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/miq_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ def action_delete_snapshots_by_age(action, rec, _inputs)
end

task_id = "action_#{action.id}_vm_#{rec.id}"
snaps_to_delete.sort_by(&:create_time).reverse.each do |s| # Delete newest to oldest
snaps_to_delete.sort_by(&:create_time).reverse_each do |s| # Delete newest to oldest
MiqPolicy.logger.info("#{log_prefix} Deleting Snapshot: Name: [#{s.name}] Id: [#{s.id}] Create Time: [#{s.create_time}]")
rec.remove_snapshot_queue(s.id, task_id)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/models/metric/ci_mixin/capture_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def verify_perf_capture_queue(last_perf_capture_on, total_queue_items)
if queue_items.any? && realtime_start_time
interval_start_time = vm.last_perf_capture_on
interval_end_time = interval_start_time + 1.day
queue_items.reverse.each do |q_item|
queue_items.reverse_each do |q_item|
verify_historical_queue_item(q_item, interval_start_time, interval_end_time)

interval_start_time = interval_end_time
Expand Down

0 comments on commit 875742e

Please sign in to comment.