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; }
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.
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;
}
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.