From c146f2c8c4eb60d063196972d5c0dd2ec550b27e Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 9 Oct 2009 13:49:55 -0700 Subject: Use the cache, Luke! --- .../Communications/CommunicationsManager.cs | 33 ++++++---------------- 1 file changed, 8 insertions(+), 25 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 2410f31..9c02842 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -210,34 +210,17 @@ namespace OpenSim.Framework.Communications private string[] doUUIDNameRequest(UUID uuid) { 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[0] = uinfo.UserProfile.FirstName; + returnstring[1] = uinfo.UserProfile.SurName; + lock (m_nameRequestCache) { - returnstring = new string[2]; - // UUID profileId = profileData.ID; - returnstring[0] = profileData.FirstName; - returnstring[1] = profileData.SurName; - lock (m_nameRequestCache) - { - if (!m_nameRequestCache.ContainsKey(uuid)) - m_nameRequestCache.Add(uuid, returnstring); - } + if (!m_nameRequestCache.ContainsKey(uuid)) + m_nameRequestCache.Add(uuid, returnstring); } } -- cgit v1.1