Menu

Caching ResourceManager lookups?

Ron
2006-08-19
2013-04-17
  • Ron

    Ron - 2006-08-19

    Is it any faster to cache lookups to the ResourceManager:

    private static string GetLocalizedString(string key)
    {
    string localizedString = (string)localizedStringCache[key];
    if (localizedString == null)
    {
      localizedString[key] = _resourceManager.GetString(key);
    }
    return localizedString;
    }

     
    • Tim Gebhardt

      Tim Gebhardt - 2006-08-21

      I ran some tests and it doesn't look like it's any faster.  Two things:

      1) The code for the caching may need to be thread safe, and that might actually slow that function down since ResourceManager.GetString already is.

      2) I looked at the GetString method with Lutz's Reflector and it's just doing a Hashtable lookup in that method anyway.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.