make some limit use of new libomv things

master
UbitUmarov 2020-05-30 15:51:01 +01:00
parent 7b8db526b3
commit b541de034c
3 changed files with 82 additions and 26 deletions

View File

@ -51,9 +51,9 @@ namespace OpenSim.Framework
public const string LLSDEmpty = "<llsd><map /></llsd>";
// got tired of creating a stringbuilder all the time;
public static StringBuilder Start(int size = 256, bool addxmlversion = false)
public static StringBuilder Start(int size = 4096, bool addxmlversion = false)
{
StringBuilder sb = new StringBuilder(size);
StringBuilder sb = osStringBuilderCache.Acquire(size);
if(addxmlversion)
sb.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><llsd>"); // legacy llsd xml name still valid
else
@ -69,13 +69,13 @@ namespace OpenSim.Framework
public static string End(StringBuilder sb)
{
sb.Append("</llsd>");
return sb.ToString();
return osStringBuilderCache.GetStringAndRelease(sb);
}
public static byte[] EndToNBBytes(StringBuilder sb)
{
sb.Append("</llsd>");
return Util.UTF8NBGetbytes(sb.ToString());
return Util.UTF8NBGetbytes(osStringBuilderCache.GetStringAndRelease(sb));
}
// map == a list of key value pairs
@ -764,11 +764,8 @@ namespace OpenSim.Framework
public static void EscapeToXML(string s, StringBuilder sb)
{
int i;
char c;
int len = s.Length;
for (i = 0; i < len; i++)
for (int i = 0; i < s.Length; ++i)
{
c = s[i];
switch (c)

View File

@ -211,8 +211,8 @@ namespace OpenSim.Framework
{"animatn", AssetType.Animation},
{"gesture", AssetType.Gesture},
{"simstate", AssetType.Simstate},
{"mesh", AssetType.Mesh}
// "settings", AssetType.Settings}
{"mesh", AssetType.Mesh},
{"settings", AssetType.Settings}
};
private static Dictionary<string, FolderType> name2Inventory = new Dictionary<string, FolderType>()
{
@ -237,7 +237,7 @@ namespace OpenSim.Framework
{"outfit", FolderType.Outfit},
{"myoutfits", FolderType.MyOutfits},
{"mesh", FolderType.Mesh},
// "settings", FolderType.Settings},
{"settings", FolderType.Settings},
{"suitcase", FolderType.Suitcase}
};

View File

@ -432,7 +432,6 @@ namespace OpenSim.Region.Framework.Scenes
for(int j = 0; j < items.Count; ++j)
{
TaskInventoryItem tii = items[j];
items[j] = null; // gc is stupid
AddForInspection(tii.AssetID, (sbyte)tii.Type);
}
@ -521,7 +520,6 @@ namespace OpenSim.Region.Framework.Scenes
return;
}
// avoid infinite loops
if (GatheredUuids.ContainsKey(assetUuid))
return;
@ -777,21 +775,83 @@ namespace OpenSim.Region.Framework.Scenes
}
}
private static byte[] wearableSeps = new byte[]{(byte)' ', (byte)'\t'};
/// <summary>
/// Record the uuids referenced by the given wearable asset
/// </summary>
/// <param name="assetBase"></param>
private void RecordWearableAssetUuids(AssetBase assetBase)
/// <param name="asset"></param>
private void RecordWearableAssetUuids(AssetBase asset)
{
//m_log.Debug(new System.Text.ASCIIEncoding().GetString(bodypartAsset.Data));
AssetWearable wearableAsset = new AssetBodypart(assetBase.FullID, assetBase.Data);
wearableAsset.Decode();
if (asset.Data == null || asset.Data.Length < 64)
return;
try
{
osUTF8 ostmp = new osUTF8(asset.Data);
if (!ostmp.SkipLine()) // version
return;
if (!ostmp.SkipLine()) // name
return;
if (!ostmp.SkipLine()) // description
return;
if (!ostmp.SkipLine())
return;
//m_log.DebugFormat(
// "[ARCHIVER]: Wearable asset {0} references {1} assets", wearableAssetUuid, wearableAsset.Textures.Count);
while(ostmp.ReadLine(out osUTF8 line))
{
line.SelfTrim(wearableSeps);
osUTF8[] parts = line.Split(wearableSeps);
if(parts[0].Lenght == 0)
continue;
parts[0].SelfTrim(wearableSeps);
if(parts[0].ToString() == "textures")
{
if(parts[1].Lenght == 0)
return;
parts[1].SelfTrim(wearableSeps);
if(!int.TryParse(parts[1].ToString(), out int count) || count == 0)
return;
for(int i = 0; i < count; ++i)
{
if(!ostmp.ReadLine(out osUTF8 texline))
return;
texline.SelfTrim(wearableSeps);
osUTF8[] texparts = texline.Split(wearableSeps);
if(texparts.Length <2 || texparts[1].Lenght < 36)
continue;
texparts[1].SelfTrim(wearableSeps);
if (UUID.TryParse(texparts[1].ToString(), out UUID id) && id != UUID.Zero)
GatheredUuids[id] = (sbyte)AssetType.Texture;
}
}
}
}
catch
{
}
}
foreach (UUID uuid in wearableAsset.Textures.Values)
GatheredUuids[uuid] = (sbyte)AssetType.Texture;
private int getxmlheader(osUTF8 data, out osUTF8 h)
{
h = data;
int st = -1;
while ((st = data.IndexOf('<')) >= 0)
{
break;
}
if (st < 0)
return -1;
++st;
int ed = -1;
while ((ed = data.IndexOf('>')) >= 0)
{
break;
}
if (ed < 0)
return -1;
h = data.osUTF8SubString(st, ed - st);
h.SelfTrim();
return ed + 1;
}
/// <summary>
@ -850,8 +910,7 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="gestureAsset"></param>
private void RecordGestureAssetUuids(AssetBase gestureAsset)
{
using (MemoryStream ms = new MemoryStream(gestureAsset.Data))
using (StreamReader sr = new StreamReader(ms))
using (StreamReader sr = new StreamReader(new MemoryStream(gestureAsset.Data)))
{
sr.ReadLine(); // Unknown (Version?)
sr.ReadLine(); // Unknown