diff --git a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs index b07ca980b2..777ca6062b 100644 --- a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs @@ -130,16 +130,12 @@ namespace OpenSim.Region.CoreModules.Framework if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId, flags)) return; */ + string capsObjectPath = GetCapsPath(agentId); Caps caps; - String capsObjectPath = GetCapsPath(agentId); - lock (m_capsObjects) { - if (m_capsObjects.ContainsKey(circuitCode)) + if (m_capsObjects.TryGetValue(circuitCode, out Caps oldCaps)) { - Caps oldCaps = m_capsObjects[circuitCode]; - - if (capsObjectPath == oldCaps.CapsObjectPath) { // m_log.WarnFormat( @@ -183,10 +179,7 @@ namespace OpenSim.Region.CoreModules.Framework m_log.DebugFormat("[CAPS]: Remove caps for agent {0} in region {1}", agentId, m_scene.RegionInfo.RegionName); lock (m_childrenSeeds) { - if (m_childrenSeeds.ContainsKey(agentId)) - { - m_childrenSeeds.Remove(agentId); - } + m_childrenSeeds.Remove(agentId); } lock (m_capsObjects) @@ -220,10 +213,8 @@ namespace OpenSim.Region.CoreModules.Framework { lock (m_capsObjects) { - if (m_capsObjects.ContainsKey(circuitCode)) - { - return m_capsObjects[circuitCode]; - } + if (m_capsObjects.TryGetValue(circuitCode, out Caps cp)) + return cp; } return null; @@ -233,10 +224,8 @@ namespace OpenSim.Region.CoreModules.Framework { lock (m_capsObjects) { - if (m_capsObjects.ContainsKey(circuitCode)) - { - m_capsObjects[circuitCode].Activate(); - } + if (m_capsObjects.TryGetValue(circuitCode, out Caps cp)) + cp.Activate(); } } @@ -254,33 +243,27 @@ namespace OpenSim.Region.CoreModules.Framework { lock (m_capsPaths) { - if (m_capsPaths.ContainsKey(agentId)) - { - return m_capsPaths[agentId]; - } + if (m_capsPaths.TryGetValue(agentId, out string path)) + return path; } - return null; } public Dictionary GetChildrenSeeds(UUID agentID) { - Dictionary seeds = null; - lock (m_childrenSeeds) - if (m_childrenSeeds.TryGetValue(agentID, out seeds)) + { + if (m_childrenSeeds.TryGetValue(agentID, out Dictionary seeds)) return seeds; - + } return new Dictionary(); } public void DropChildSeed(UUID agentID, ulong handle) { - Dictionary seeds; - lock (m_childrenSeeds) { - if (m_childrenSeeds.TryGetValue(agentID, out seeds)) + if (m_childrenSeeds.TryGetValue(agentID, out Dictionary seeds)) { seeds.Remove(handle); } @@ -289,18 +272,14 @@ namespace OpenSim.Region.CoreModules.Framework public string GetChildSeed(UUID agentID, ulong handle) { - Dictionary seeds; - string returnval; - lock (m_childrenSeeds) { - if (m_childrenSeeds.TryGetValue(agentID, out seeds)) + if (m_childrenSeeds.TryGetValue(agentID, out Dictionary seeds)) { - if (seeds.TryGetValue(handle, out returnval)) + if (seeds.TryGetValue(handle, out string returnval)) return returnval; } } - return null; }