Use only one (static) (de-)serializer for (de-)serializing SOPs.

That improves performance drastically, at least for Mono, as the
(de-)serializers can then be optimized (and won't use reflection anymore).
On my system, before this change de-/serialization took ~9s/9s, whereas
after the change it takes ~.5/.2s.
This commit is contained in:
Homer Horwitz
2009-01-02 17:22:24 +00:00
parent fbd664ca84
commit 09378da127
2 changed files with 27 additions and 6 deletions

View File

@@ -96,7 +96,11 @@ namespace OpenSim.Region.Environment.Scenes
public class SceneObjectPart : IScriptHost, ISerializable
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
// use only one serializer to give the runtime a chance to optimize it (it won't do that if you
// use a new instance every time)
private static XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart));
#region Fields
[XmlIgnore]
@@ -1619,7 +1623,6 @@ if (m_shape != null) {
/// <returns></returns>
public static SceneObjectPart FromXml(UUID fromUserInventoryItemId, XmlReader xmlReader)
{
XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart));
SceneObjectPart part = (SceneObjectPart)serializer.Deserialize(xmlReader);
part.m_fromUserInventoryItemID = fromUserInventoryItemId;
@@ -3186,7 +3189,6 @@ if (m_shape != null) {
/// <param name="xmlWriter"></param>
public void ToXml(XmlWriter xmlWriter)
{
XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart));
serializer.Serialize(xmlWriter, this);
}