From 387d564aadc38c28af78d5b60a3bad57f1a8a2d5 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Wed, 24 Aug 2016 07:41:11 +0100
Subject: do similar changes to unused checksManager
---
OpenSim/Framework/Monitoring/ChecksManager.cs | 45 +++++++++++++--------------
OpenSim/Framework/Monitoring/StatsManager.cs | 3 --
2 files changed, 21 insertions(+), 27 deletions(-)
diff --git a/OpenSim/Framework/Monitoring/ChecksManager.cs b/OpenSim/Framework/Monitoring/ChecksManager.cs
index e4a7f8c..ff3b041 100644
--- a/OpenSim/Framework/Monitoring/ChecksManager.cs
+++ b/OpenSim/Framework/Monitoring/ChecksManager.cs
@@ -132,8 +132,8 @@ namespace OpenSim.Framework.Monitoring
///
public static bool RegisterCheck(Check check)
{
- SortedDictionary> category = null, newCategory;
- SortedDictionary container = null, newContainer;
+ SortedDictionary> category = null;
+ SortedDictionary container = null;
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.
// 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)
- newContainer = new SortedDictionary(container);
- else
- newContainer = new SortedDictionary();
+ if (container == null)
+ container = new SortedDictionary();
- if (category != null)
- newCategory = new SortedDictionary>(category);
- else
- newCategory = new SortedDictionary>();
+ if (category == null)
+ category = new SortedDictionary>();
- newContainer[check.ShortName] = check;
- newCategory[check.Container] = newContainer;
- RegisteredChecks[check.Category] = newCategory;
+ container[check.ShortName] = check;
+ category[check.Container] = container;
+ RegisteredChecks[check.Category] = category;
}
return true;
@@ -171,23 +167,24 @@ namespace OpenSim.Framework.Monitoring
///
public static bool DeregisterCheck(Check check)
{
- SortedDictionary> category = null, newCategory;
- SortedDictionary container = null, newContainer;
+ SortedDictionary> category = null;
+ SortedDictionary container = null;
lock (RegisteredChecks)
{
if (!TryGetCheckParents(check, out category, out container))
return false;
- newContainer = new SortedDictionary(container);
- newContainer.Remove(check.ShortName);
-
- newCategory = new SortedDictionary>(category);
- newCategory.Remove(check.Container);
-
- newCategory[check.Container] = newContainer;
- RegisteredChecks[check.Category] = newCategory;
-
+ if(container != null)
+ {
+ container.Remove(check.ShortName);
+ if(category != null && container.Count == 0)
+ {
+ category.Remove(check.Container);
+ if(category.Count == 0)
+ RegisteredChecks.Remove(check.Category);
+ }
+ }
return true;
}
}
diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs
index c0be87b..6277d44 100644
--- a/OpenSim/Framework/Monitoring/StatsManager.cs
+++ b/OpenSim/Framework/Monitoring/StatsManager.cs
@@ -363,9 +363,6 @@ namespace OpenSim.Framework.Monitoring
if (TryGetStatParents(stat, out category, out container))
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)
container = new SortedDictionary();
--
cgit v1.1