From 32396742f86fb5336de5acd4e2a05099f111022a Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Wed, 24 Aug 2016 06:26:31 +0100
Subject: reduce unnecessary allocation of new items
---
OpenSim/Framework/Monitoring/StatsManager.cs | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
(limited to 'OpenSim/Framework')
diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs
index 8787ea0..008127e 100644
--- a/OpenSim/Framework/Monitoring/StatsManager.cs
+++ b/OpenSim/Framework/Monitoring/StatsManager.cs
@@ -361,8 +361,8 @@ namespace OpenSim.Framework.Monitoring
///
public static bool RegisterStat(Stat stat)
{
- SortedDictionary> category = null, newCategory;
- SortedDictionary container = null, newContainer;
+ SortedDictionary> category = null;
+ SortedDictionary container = null;
lock (RegisteredStats)
{
@@ -375,19 +375,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[stat.ShortName] = stat;
- newCategory[stat.Container] = newContainer;
- RegisteredStats[stat.Category] = newCategory;
+ container[stat.ShortName] = stat;
+ category[stat.Container] = container;
+ RegisteredStats[stat.Category] = category;
}
return true;
--
cgit v1.1