mirror of
https://github.com/opensim/opensim.git
synced 2026-05-15 19:35:41 +08:00
try improve lsl list compare with null, hopefuly not looping for ever
This commit is contained in:
@@ -679,7 +679,10 @@ namespace OpenSim.Region.ScriptEngine.Shared
|
||||
get
|
||||
{
|
||||
if (m_data == null)
|
||||
{
|
||||
m_data=new object[0];
|
||||
return 0;
|
||||
}
|
||||
return m_data.Length;
|
||||
}
|
||||
}
|
||||
@@ -923,26 +926,20 @@ namespace OpenSim.Region.ScriptEngine.Shared
|
||||
|
||||
public static bool operator ==(list a, list b)
|
||||
{
|
||||
int la = -1;
|
||||
int lb = -1;
|
||||
try { la = a.Length; }
|
||||
catch (NullReferenceException) { }
|
||||
try { lb = b.Length; }
|
||||
catch (NullReferenceException) { }
|
||||
|
||||
return la == lb;
|
||||
if (b is null)
|
||||
return (a is null);
|
||||
if (a is null)
|
||||
return (b is null);
|
||||
return a.Length == b.Length;
|
||||
}
|
||||
|
||||
public static bool operator !=(list a, list b)
|
||||
{
|
||||
int la = -1;
|
||||
int lb = -1;
|
||||
try { la = a.Length; }
|
||||
catch (NullReferenceException) { }
|
||||
try { lb = b.Length; }
|
||||
catch (NullReferenceException) { }
|
||||
|
||||
return la != lb;
|
||||
if (b is null)
|
||||
return !(a is null);
|
||||
if (a is null)
|
||||
return !(b is null);
|
||||
return a.Length != b.Length;
|
||||
}
|
||||
|
||||
public void Add(object o)
|
||||
|
||||
@@ -105,33 +105,19 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
|
||||
public void Save(LSL_List lis)
|
||||
{
|
||||
if (lis == null)
|
||||
usage = instance.UpdateLocalsHeapUse(usage, 0);
|
||||
else
|
||||
usage = instance.UpdateLocalsHeapUse(usage, Size(lis));
|
||||
usage = (lis == null) ? instance.UpdateLocalsHeapUse(usage, 0) : instance.UpdateLocalsHeapUse(usage, lis.Size);
|
||||
value = lis;
|
||||
}
|
||||
|
||||
public void Restore(LSL_List lis)
|
||||
{
|
||||
value = lis;
|
||||
if (lis != null)
|
||||
usage = Size(lis);
|
||||
else
|
||||
usage = 0;
|
||||
usage = (lis is null) ? 0 : lis.Size;
|
||||
}
|
||||
|
||||
//private static int counter = 5;
|
||||
public static int Size(LSL_List lis)
|
||||
{
|
||||
try
|
||||
{
|
||||
return lis.Size;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return lis is null ? 0 : lis.Size;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -237,7 +237,10 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
if (liss != null)
|
||||
{
|
||||
foreach (LSL_List lis in liss)
|
||||
newheapuse += HeapTrackerList.Size(lis);
|
||||
{
|
||||
if(!(lis is null))
|
||||
newheapuse += lis.Size;
|
||||
}
|
||||
iarLists = liss;
|
||||
}
|
||||
else
|
||||
@@ -322,7 +325,10 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
if(iarLists != null)
|
||||
{
|
||||
foreach(LSL_List lis in iarLists)
|
||||
newheapuse -= HeapTrackerList.Size(lis);
|
||||
{
|
||||
if (!(lis is null))
|
||||
newheapuse += lis.Size;
|
||||
}
|
||||
iarLists = null;
|
||||
}
|
||||
if(iarObjects != null)
|
||||
|
||||
Reference in New Issue
Block a user