OPTIMIZATION : why LanguageManager.GetAllLanguages(false) is called even if it is not used?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 years ago
Look at this example :  


      public Language WorkingLanguage
        {
            get
            {
                var customer = NopContext.Current.User;

                var publishedLanguages = LanguageManager.GetAllLanguages(false); // !!! Called here !!!

                if (customer != null)
                {
                    var customerLanguage = customer.Language;
                    if (customerLanguage != null && customerLanguage.Published)
                        return customerLanguage;
                }
                else if (CommonHelper.GetCookieInt("Nop.CustomerLanguage") > 0)
                {
                    var customerLanguage = LanguageManager.GetLanguageById(CommonHelper.GetCookieInt("Nop.CustomerLanguage"));
                    if (customerLanguage != null)
                        if (customerLanguage != null && customerLanguage.Published)
                            return customerLanguage;
                }

                // !!! Should be called here ? !!!

                foreach (var _language in publishedLanguages) // !!! Rarely used here !!!
                    return _language;

                throw new NopException("Languages could not be loaded");
            }
13 years ago
Nicolas,

You're absolutely right. Thanks for info
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.