try improve lsl list compare with null, hopefuly not looping for ever

This commit is contained in:
UbitUmarov
2022-05-04 19:24:16 +01:00
parent a1e32e37da
commit df03e64f5c
3 changed files with 24 additions and 35 deletions

View File

@@ -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)

View File

@@ -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;
}
}

View File

@@ -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)