change InventoryStringBuilder. This will do much for mantis 7904 objects inventory sending is slow by design

LSLKeyTest
UbitUmarov 2016-07-07 14:38:27 +01:00
parent f768effa87
commit 14b9d31bd9
1 changed files with 21 additions and 12 deletions

View File

@ -26,6 +26,7 @@
*/ */
using System; using System;
using System.Text;
using System.Xml; using System.Xml;
using System.IO; using System.IO;
using System.Collections.Generic; using System.Collections.Generic;
@ -1217,7 +1218,8 @@ namespace OpenSim.Region.Framework.Scenes
Items.LockItemsForRead(false); Items.LockItemsForRead(false);
m_inventoryFileData = Utils.StringToBytes(invString.BuildString); m_inventoryFileData = Utils.StringToBytes(invString.GetString());
invString.Close();
if (m_inventoryFileData.Length > 2) if (m_inventoryFileData.Length > 2)
{ {
@ -1261,11 +1263,11 @@ namespace OpenSim.Region.Framework.Scenes
public class InventoryStringBuilder public class InventoryStringBuilder
{ {
public string BuildString = String.Empty; private StringBuilder BuildString = new StringBuilder(16384);
public InventoryStringBuilder(UUID folderID, UUID parentID) public InventoryStringBuilder(UUID folderID, UUID parentID)
{ {
BuildString += "\tinv_object\t0\n\t{\n"; BuildString.Append("\tinv_object\t0\n\t{\n");
AddNameValueLine("obj_id", folderID.ToString()); AddNameValueLine("obj_id", folderID.ToString());
AddNameValueLine("parent_id", parentID.ToString()); AddNameValueLine("parent_id", parentID.ToString());
AddNameValueLine("type", "category"); AddNameValueLine("type", "category");
@ -1275,46 +1277,53 @@ namespace OpenSim.Region.Framework.Scenes
public void AddItemStart() public void AddItemStart()
{ {
BuildString += "\tinv_item\t0\n"; BuildString.Append("\tinv_item\t0\n");
AddSectionStart(); AddSectionStart();
} }
public void AddPermissionsStart() public void AddPermissionsStart()
{ {
BuildString += "\tpermissions 0\n"; BuildString.Append("\tpermissions 0\n");
AddSectionStart(); AddSectionStart();
} }
public void AddSaleStart() public void AddSaleStart()
{ {
BuildString += "\tsale_info\t0\n"; BuildString.Append("\tsale_info\t0\n");
AddSectionStart(); AddSectionStart();
} }
protected void AddSectionStart() protected void AddSectionStart()
{ {
BuildString += "\t{\n"; BuildString.Append("\t{\n");
} }
public void AddSectionEnd() public void AddSectionEnd()
{ {
BuildString += "\t}\n"; BuildString.Append("\t}\n");
} }
public void AddLine(string addLine) public void AddLine(string addLine)
{ {
BuildString += addLine; BuildString.Append(addLine);
} }
public void AddNameValueLine(string name, string value) public void AddNameValueLine(string name, string value)
{ {
BuildString += "\t\t"; BuildString.Append("\t\t");
BuildString += name + "\t"; BuildString.Append(name + "\t");
BuildString += value + "\n"; BuildString.Append(value + "\n");
}
public String GetString()
{
return BuildString.ToString();
} }
public void Close() public void Close()
{ {
BuildString.Clear();
BuildString = null;
} }
} }