Reorder conditions for performance

A little micro-optimisation: `@order.checkout_allowed?` requires a database query, whereas `@order.completed?` does not. So in cases where the order is completed we can return early here before hitting the database.
This commit is contained in:
Matt-Yorkley
2021-11-14 12:41:14 +00:00
parent 8d0cbe886a
commit 1bf4e6fa56

View File

@@ -89,9 +89,7 @@ class CheckoutController < ::BaseController
end
def order_invalid_for_checkout?
!@order ||
!@order.checkout_allowed? ||
@order.completed?
!@order || @order.completed? || !@order.checkout_allowed?
end
def valid_order_line_items?