From 387e9f7a7faeb412054383080afc3507a1522746 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Fri, 2 Oct 2009 18:31:08 -0700 Subject: * Creates Util.UTF8 and switches some references of Encoding.UTF8 to Util.UTF8 (not all references were switched since not all OpenSim libraries reference OpenSim.Framework) * Shrinks the largest in-memory object, the LLRAW.HeightmapLookupValue struct (only used for exporting to LLRAW terrain files), to the minimum possible size. This seems to have the odd side effect of cutting the size of the two double[256,256] terrain objects in half. Possibly an alignment optimization? --- OpenSim/Framework/AssetLandmark.cs | 2 +- OpenSim/Framework/Capabilities/LLSD.cs | 4 ++-- OpenSim/Framework/Capabilities/LLSDStreamHandler.cs | 2 +- OpenSim/Framework/Communications/XMPP/XmppWriter.cs | 2 +- OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs | 2 +- OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 2 +- OpenSim/Framework/Util.cs | 12 +++++++----- 7 files changed, 14 insertions(+), 12 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/AssetLandmark.cs b/OpenSim/Framework/AssetLandmark.cs index 7c87c34..fd7a2cd 100644 --- a/OpenSim/Framework/AssetLandmark.cs +++ b/OpenSim/Framework/AssetLandmark.cs @@ -49,7 +49,7 @@ namespace OpenSim.Framework private void InternData() { - string temp = Encoding.UTF8.GetString(Data).Trim(); + string temp = Util.UTF8.GetString(Data).Trim(); string[] parts = temp.Split('\n'); int.TryParse(parts[0].Substring(17, 1), out Version); UUID.TryParse(parts[1].Substring(10, 36), out RegionID); diff --git a/OpenSim/Framework/Capabilities/LLSD.cs b/OpenSim/Framework/Capabilities/LLSD.cs index 84f43c1..eec9e61 100644 --- a/OpenSim/Framework/Capabilities/LLSD.cs +++ b/OpenSim/Framework/Capabilities/LLSD.cs @@ -112,7 +112,7 @@ namespace OpenSim.Framework.Capabilities writer.Close(); - return Encoding.UTF8.GetBytes(sw.ToString()); + return Util.UTF8.GetBytes(sw.ToString()); } /// @@ -329,7 +329,7 @@ namespace OpenSim.Framework.Capabilities reader.Read(); FromBase64Transform b64 = new FromBase64Transform(FromBase64TransformMode.IgnoreWhiteSpaces); - byte[] inp = Encoding.UTF8.GetBytes(reader.ReadString()); + byte[] inp = Util.UTF8.GetBytes(reader.ReadString()); ret = b64.TransformFinalBlock(inp, 0, inp.Length); break; } diff --git a/OpenSim/Framework/Capabilities/LLSDStreamHandler.cs b/OpenSim/Framework/Capabilities/LLSDStreamHandler.cs index df48b35..7aaa994 100644 --- a/OpenSim/Framework/Capabilities/LLSDStreamHandler.cs +++ b/OpenSim/Framework/Capabilities/LLSDStreamHandler.cs @@ -47,7 +47,7 @@ namespace OpenSim.Framework.Capabilities public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { - //Encoding encoding = Encoding.UTF8; + //Encoding encoding = Util.UTF8; //StreamReader streamReader = new StreamReader(request, false); //string requestBody = streamReader.ReadToEnd(); diff --git a/OpenSim/Framework/Communications/XMPP/XmppWriter.cs b/OpenSim/Framework/Communications/XMPP/XmppWriter.cs index b52eda7..415d808 100644 --- a/OpenSim/Framework/Communications/XMPP/XmppWriter.cs +++ b/OpenSim/Framework/Communications/XMPP/XmppWriter.cs @@ -38,7 +38,7 @@ namespace OpenSim.Framework.Communications.XMPP { } - public XMPPWriter(IOStream stream) : this(stream, Encoding.UTF8) + public XMPPWriter(IOStream stream) : this(stream, Util.UTF8) { } diff --git a/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs b/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs index 318d2c3..3dce578 100644 --- a/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs +++ b/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs @@ -77,7 +77,7 @@ namespace OpenSim.Framework.Configuration.HTTP count = resStream.Read(buf, 0, buf.Length); if (count != 0) { - tempString = Encoding.UTF8.GetString(buf, 0, count); + tempString = Util.UTF8.GetString(buf, 0, count); sb.Append(tempString); } } while (count > 0); diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 771ae05..f314d64 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -965,7 +965,7 @@ namespace OpenSim.Framework.Servers.HttpServer } // response.ContentType = "application/llsd+json"; - // return Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(llsdResponse)); + // return Util.UTF8.GetBytes(OSDParser.SerializeJsonString(llsdResponse)); response.ContentType = "application/llsd+xml"; return OSDParser.SerializeLLSDXmlBytes(llsdResponse); } diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 58344f3..59159a8 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -69,7 +69,9 @@ namespace OpenSim.Framework public static readonly Regex UUIDPattern = new Regex("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"); - + + public static Encoding UTF8 = Encoding.UTF8; + /// /// Well known UUID for the blank texture used in the Linden SL viewer version 1.20 (and hopefully onwards) /// @@ -432,7 +434,7 @@ namespace OpenSim.Framework output.Append(": "); } - output.Append(CleanString(Encoding.UTF8.GetString(bytes, 0, bytes.Length - 1))); + output.Append(CleanString(Util.UTF8.GetString(bytes, 0, bytes.Length - 1))); } else { @@ -793,7 +795,7 @@ namespace OpenSim.Framework public static string Compress(string text) { - byte[] buffer = Encoding.UTF8.GetBytes(text); + byte[] buffer = Util.UTF8.GetBytes(text); MemoryStream memory = new MemoryStream(); using (GZipStream compressor = new GZipStream(memory, CompressionMode.Compress, true)) { @@ -827,7 +829,7 @@ namespace OpenSim.Framework decompressor.Read(buffer, 0, buffer.Length); } - return Encoding.UTF8.GetString(buffer); + return Util.UTF8.GetString(buffer); } } @@ -1099,7 +1101,7 @@ namespace OpenSim.Framework { byte[] data = new byte[length]; stream.Read(data, 0, length); - string strdata = Encoding.UTF8.GetString(data); + string strdata = Util.UTF8.GetString(data); OSDMap args = null; OSD buffer; buffer = OSDParser.DeserializeJson(strdata); -- cgit v1.1