Cosmetic fix

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 years ago
This is very small performance optimization (cosmetic fix).
PriceCalculationService.cs

I want to change two conditions
Old code


            foreach (var discount in product.AppliedDiscounts)
            {
                if (_discountService.ValidateDiscount(discount, customer).IsValid &&
                    discount.DiscountType == DiscountType.AssignedToSkus)
                    allowedDiscounts.Add(_discountService.MapDiscount(discount));
            }


new code


            foreach (var discount in product.AppliedDiscounts)
            {
                if (discount.DiscountType == DiscountType.AssignedToSkus && _discountService.ValidateDiscount(discount, customer).IsValid)
                    allowedDiscounts.Add(_discountService.MapDiscount(discount));
            }


and for category and manufacturer (two places)
old code

                    if (_discountService.ValidateDiscount(discount, customer).IsValid &&
                        !_discountService.ContainsDiscount(allowedDiscounts, discount))
                        allowedDiscounts.Add(discount);


new code
                    if (!_discountService.ContainsDiscount(allowedDiscounts, discount) && _discountService.ValidateDiscount(discount, customer).IsValid)
                        allowedDiscounts.Add(discount);
5 years ago
Thanks for the suggestion. Here is a work item.
5 years ago
Done. Please see this commit for more details.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.