do similar changes to unused checksManager

LSLKeyTest
UbitUmarov 2016-08-24 07:41:11 +01:00
parent fc45942026
commit 387d564aad
2 changed files with 21 additions and 27 deletions

View File

@ -132,8 +132,8 @@ namespace OpenSim.Framework.Monitoring
/// <returns></returns> /// <returns></returns>
public static bool RegisterCheck(Check check) public static bool RegisterCheck(Check check)
{ {
SortedDictionary<string, SortedDictionary<string, Check>> category = null, newCategory; SortedDictionary<string, SortedDictionary<string, Check>> category = null;
SortedDictionary<string, Check> container = null, newContainer; SortedDictionary<string, Check> container = null;
lock (RegisteredChecks) lock (RegisteredChecks)
{ {
@ -146,19 +146,15 @@ namespace OpenSim.Framework.Monitoring
// We take a copy-on-write approach here of replacing dictionaries when keys are added or removed. // We take a copy-on-write approach here of replacing dictionaries when keys are added or removed.
// This means that we don't need to lock or copy them on iteration, which will be a much more // This means that we don't need to lock or copy them on iteration, which will be a much more
// common operation after startup. // common operation after startup.
if (container != null) if (container == null)
newContainer = new SortedDictionary<string, Check>(container); container = new SortedDictionary<string, Check>();
else
newContainer = new SortedDictionary<string, Check>();
if (category != null) if (category == null)
newCategory = new SortedDictionary<string, SortedDictionary<string, Check>>(category); category = new SortedDictionary<string, SortedDictionary<string, Check>>();
else
newCategory = new SortedDictionary<string, SortedDictionary<string, Check>>();
newContainer[check.ShortName] = check; container[check.ShortName] = check;
newCategory[check.Container] = newContainer; category[check.Container] = container;
RegisteredChecks[check.Category] = newCategory; RegisteredChecks[check.Category] = category;
} }
return true; return true;
@ -171,23 +167,24 @@ namespace OpenSim.Framework.Monitoring
/// <returns></returns> /// <returns></returns>
public static bool DeregisterCheck(Check check) public static bool DeregisterCheck(Check check)
{ {
SortedDictionary<string, SortedDictionary<string, Check>> category = null, newCategory; SortedDictionary<string, SortedDictionary<string, Check>> category = null;
SortedDictionary<string, Check> container = null, newContainer; SortedDictionary<string, Check> container = null;
lock (RegisteredChecks) lock (RegisteredChecks)
{ {
if (!TryGetCheckParents(check, out category, out container)) if (!TryGetCheckParents(check, out category, out container))
return false; return false;
newContainer = new SortedDictionary<string, Check>(container); if(container != null)
newContainer.Remove(check.ShortName); {
container.Remove(check.ShortName);
newCategory = new SortedDictionary<string, SortedDictionary<string, Check>>(category); if(category != null && container.Count == 0)
newCategory.Remove(check.Container); {
category.Remove(check.Container);
newCategory[check.Container] = newContainer; if(category.Count == 0)
RegisteredChecks[check.Category] = newCategory; RegisteredChecks.Remove(check.Category);
}
}
return true; return true;
} }
} }

View File

@ -363,9 +363,6 @@ namespace OpenSim.Framework.Monitoring
if (TryGetStatParents(stat, out category, out container)) if (TryGetStatParents(stat, out category, out container))
return false; return false;
// We take a copy-on-write approach here of replacing dictionaries when keys are added or removed.
// This means that we don't need to lock or copy them on iteration, which will be a much more
// common operation after startup.
if (container == null) if (container == null)
container = new SortedDictionary<string, Stat>(); container = new SortedDictionary<string, Stat>();