Use the cache, Luke!

prioritization
Diva Canto 2009-10-09 13:49:55 -07:00
parent 8231cb2231
commit c146f2c8c4
1 changed files with 8 additions and 25 deletions

View File

@ -210,36 +210,19 @@ namespace OpenSim.Framework.Communications
private string[] doUUIDNameRequest(UUID uuid) private string[] doUUIDNameRequest(UUID uuid)
{ {
string[] returnstring = new string[0]; string[] returnstring = new string[0];
bool doLookup = false; CachedUserInfo uinfo = UserProfileCacheService.GetUserDetails(uuid);
lock (m_nameRequestCache) if ((uinfo != null) && (uinfo.UserProfile != null))
{
if (m_nameRequestCache.ContainsKey(uuid))
{
returnstring = m_nameRequestCache[uuid];
}
else
{
// we don't want to lock the dictionary while we're doing the lookup
doLookup = true;
}
}
if (doLookup) {
UserProfileData profileData = m_userService.GetUserProfile(uuid);
if (profileData != null)
{ {
returnstring = new string[2]; returnstring = new string[2];
// UUID profileId = profileData.ID; returnstring[0] = uinfo.UserProfile.FirstName;
returnstring[0] = profileData.FirstName; returnstring[1] = uinfo.UserProfile.SurName;
returnstring[1] = profileData.SurName;
lock (m_nameRequestCache) lock (m_nameRequestCache)
{ {
if (!m_nameRequestCache.ContainsKey(uuid)) if (!m_nameRequestCache.ContainsKey(uuid))
m_nameRequestCache.Add(uuid, returnstring); m_nameRequestCache.Add(uuid, returnstring);
} }
} }
}
return returnstring; return returnstring;
} }