YAFLogo

thethanghn
  • thethanghn
  • 60.8% (Friendly)
  • YAF Camper Topic Starter
12 years ago
Hi,
As I look into YAF.Classes.Config class, I found that each of Property will search through the AppSettings collection and get the value from it. I think there is 2 points would be slow:
- Unnecessary look up
- Retrieve value from config file again and again

Whether it'd better if we cache them in separate static variable?

Sincerely
Thangnt
Sponsor

thethanghn
  • thethanghn
  • 60.8% (Friendly)
  • YAF Camper Topic Starter
12 years ago
Some of refactored code:


public static string BoardID
    {
      get
      {
        if (string.IsNullOrEmpty(boardID))
          boardID = GetConfigValueAsString("YAF.BoardID") ?? "1";
        return boardID;
      }
    }

    public static bool DisableJQuery
    {
      get
      {
        if (!disableJQuery.HasValue)
          disableJQuery = GetConfigValueAsBool("YAF.DisableJQuery", false);
        return disableJQuery.Value;
      }
    }
Jaben
  • Jaben
  • 100% (Exalted)
  • YAF Developer
12 years ago
I've done extensive performance profiling of the YAF project. This has never come up as a place that needed refactoring for performance reasons.

There is always "better" code... but instead of your solution I'd offer a complete abstraction of the configuration system that provided a caching system.
YAF Logo Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved
About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button