reduce unnecessary allocation of new items
parent
99c3b61bd9
commit
32396742f8
|
@ -361,8 +361,8 @@ namespace OpenSim.Framework.Monitoring
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool RegisterStat(Stat stat)
|
public static bool RegisterStat(Stat stat)
|
||||||
{
|
{
|
||||||
SortedDictionary<string, SortedDictionary<string, Stat>> category = null, newCategory;
|
SortedDictionary<string, SortedDictionary<string, Stat>> category = null;
|
||||||
SortedDictionary<string, Stat> container = null, newContainer;
|
SortedDictionary<string, Stat> container = null;
|
||||||
|
|
||||||
lock (RegisteredStats)
|
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.
|
// 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, Stat>(container);
|
container = new SortedDictionary<string, Stat>();
|
||||||
else
|
|
||||||
newContainer = new SortedDictionary<string, Stat>();
|
|
||||||
|
|
||||||
if (category != null)
|
if (category == null)
|
||||||
newCategory = new SortedDictionary<string, SortedDictionary<string, Stat>>(category);
|
category = new SortedDictionary<string, SortedDictionary<string, Stat>>();
|
||||||
else
|
|
||||||
newCategory = new SortedDictionary<string, SortedDictionary<string, Stat>>();
|
|
||||||
|
|
||||||
newContainer[stat.ShortName] = stat;
|
container[stat.ShortName] = stat;
|
||||||
newCategory[stat.Container] = newContainer;
|
category[stat.Container] = container;
|
||||||
RegisteredStats[stat.Category] = newCategory;
|
RegisteredStats[stat.Category] = category;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue