YAFLogo

thethanghn
  • thethanghn
  • 60.8% (Friendly)
  • YAF Camper Topic Starter
2010-10-29T01:31:49Z
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
2010-10-29T04:48:55Z
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
2010-10-29T05:24:32Z
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.


UserPostedImage