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/Region/Application/OpenSimBase.cs | 6 +++--- OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 4 ++-- .../Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs | 4 ++-- .../CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs | 4 ++-- OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs | 10 +++++----- OpenSim/Region/DataSnapshot/DataSnapshotManager.cs | 2 +- OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs | 2 +- OpenSim/Region/Framework/Scenes/TerrainChannel.cs | 2 +- .../Agent/InternetRelayClientView/Server/IRCClientView.cs | 4 ++-- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 4 ++-- .../OptionalModules/World/TreePopulator/TreePopulatorModule.cs | 2 +- .../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +- .../Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 2 +- 13 files changed, 24 insertions(+), 24 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 7bc0b77..6b6cb85 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -699,7 +699,7 @@ namespace OpenSim public byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { - return Encoding.UTF8.GetBytes("OK"); + return Util.UTF8.GetBytes("OK"); } public string ContentType @@ -736,7 +736,7 @@ namespace OpenSim public byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { - return Encoding.UTF8.GetBytes(m_opensim.StatReport(httpRequest)); + return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest)); } public string ContentType @@ -777,7 +777,7 @@ namespace OpenSim public byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { - return Encoding.UTF8.GetBytes(m_opensim.StatReport(httpRequest)); + return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest)); } public string ContentType diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 43d29fd..3f90004 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -4748,7 +4748,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP { Hashtable mp = (Hashtable)simMapProfiles[iii]; mbReply.Data[iii] = new MapBlockReplyPacket.DataBlock(); - mbReply.Data[iii].Name = System.Text.Encoding.UTF8.GetBytes((string)mp["name"]); + mbReply.Data[iii].Name = Util.UTF8.GetBytes((string)mp["name"]); mbReply.Data[iii].Access = System.Convert.ToByte(mp["access"]); mbReply.Data[iii].Agents = System.Convert.ToByte(mp["agents"]); mbReply.Data[iii].MapImageID = new UUID((string)mp["map-image-id"]); @@ -7338,7 +7338,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - string mapName = Encoding.UTF8.GetString(map.NameData.Name, 0, + string mapName = Util.UTF8.GetString(map.NameData.Name, 0, map.NameData.Name.Length - 1); handlerMapNameRequest = OnMapNameRequest; if (handlerMapNameRequest != null) diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs index a0f359b..7456e8c 100644 --- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs +++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs @@ -257,7 +257,7 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender stringResult.AppendFormat("{0}|{1}|{2}{3}", Layers[i].Start, Layers[i].End, Layers[i].End - Layers[i].Start, strEnd); } - layerDecodeAsset.Data = Encoding.UTF8.GetBytes(stringResult.ToString()); + layerDecodeAsset.Data = Util.UTF8.GetBytes(stringResult.ToString()); #endregion Serialize Layer Data @@ -280,7 +280,7 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender { #region Deserialize Layer Data - string readResult = Encoding.UTF8.GetString(layerDecodeAsset.Data); + string readResult = Util.UTF8.GetString(layerDecodeAsset.Data); string[] lines = readResult.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); if (lines.Length == 0) diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index 50d7c97..45e724d 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs @@ -367,7 +367,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest // Encode outbound data if (OutboundBody.Length > 0) { - byte[] data = Encoding.UTF8.GetBytes(OutboundBody); + byte[] data = Util.UTF8.GetBytes(OutboundBody); Request.ContentLength = data.Length; Stream bstream = Request.GetRequestStream(); @@ -390,7 +390,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest if (count != 0) { // translate from bytes to ASCII text - tempString = Encoding.UTF8.GetString(buf, 0, count); + tempString = Util.UTF8.GetString(buf, 0, count); // continue building the string sb.Append(tempString); diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs index 3eb7cd2..a70ef13 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs @@ -36,10 +36,10 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders { public struct HeightmapLookupValue : IComparable { - public int Index; - public double Value; + public ushort Index; + public float Value; - public HeightmapLookupValue(int index, double value) + public HeightmapLookupValue(ushort index, float value) { Index = index; Value = value; @@ -62,7 +62,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders { for (int j = 0; j < 256; j++) { - LookupHeightTable[i + (j * 256)] = new HeightmapLookupValue(i + (j * 256), ((double)i * ((double)j / 128.0d))); + LookupHeightTable[i + (j * 256)] = new HeightmapLookupValue((ushort)(i + (j * 256)), (float)((double)i * ((double)j / 128.0d))); } } Array.Sort(LookupHeightTable); @@ -196,7 +196,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders // The lookup table is pre-sorted, so we either find an exact match or // the next closest (smaller) match with a binary search - index = Array.BinarySearch(LookupHeightTable, new HeightmapLookupValue(0, t)); + index = Array.BinarySearch(LookupHeightTable, new HeightmapLookupValue(0, (float)t)); if (index < 0) index = ~index - 1; diff --git a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs index 080bd5a..4df9094 100644 --- a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs +++ b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs @@ -352,7 +352,7 @@ namespace OpenSim.Region.DataSnapshot m_log.WarnFormat("[DATASNAPSHOT]: Unable to decode reply from data service. Ignoring. {0}", e.StackTrace); } // This is not quite working, so... - // string responseStr = Encoding.UTF8.GetString(response); + // string responseStr = Util.UTF8.GetString(response); m_log.Info("[DATASNAPSHOT]: data service notified: " + url); } diff --git a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs index 7c02f9a..6055384 100644 --- a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs +++ b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs @@ -73,7 +73,7 @@ namespace OpenSim.Region.Framework.Scenes public byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { - return Encoding.UTF8.GetBytes(Report()); + return Util.UTF8.GetBytes(Report()); } public string ContentType diff --git a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs index 8209ff6..ca6210d 100644 --- a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs +++ b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs @@ -172,7 +172,7 @@ namespace OpenSim.Region.Framework.Scenes public string SaveToXmlString() { XmlWriterSettings settings = new XmlWriterSettings(); - settings.Encoding = Encoding.UTF8; + settings.Encoding = Util.UTF8; using (StringWriter sw = new StringWriter()) { using (XmlWriter writer = XmlWriter.Create(sw, settings)) diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 57f5d29..a31cbae 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -81,7 +81,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server { m_log.Info("[IRCd] Sending >>> " + command); - byte[] buf = Encoding.UTF8.GetBytes(command + "\r\n"); + byte[] buf = Util.UTF8.GetBytes(command + "\r\n"); m_client.GetStream().BeginWrite(buf, 0, buf.Length, SendComplete, null); } @@ -109,7 +109,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server byte[] buf = new byte[8]; // RFC1459 defines max message size as 512. int count = m_client.GetStream().Read(buf, 0, buf.Length); - string line = Encoding.UTF8.GetString(buf, 0, count); + string line = Util.UTF8.GetString(buf, 0, count); strbuf += line; diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 65c5274..f9dfc0d 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -527,7 +527,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice if (method == "POST") { - byte[] contentreq = Encoding.UTF8.GetBytes(body); + byte[] contentreq = Util.UTF8.GetBytes(body); forwardreq.ContentLength = contentreq.Length; Stream reqStream = forwardreq.GetRequestStream(); reqStream.Write(contentreq, 0, contentreq.Length); @@ -535,7 +535,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice } HttpWebResponse fwdrsp = (HttpWebResponse)forwardreq.GetResponse(); - Encoding encoding = Encoding.UTF8; + Encoding encoding = Util.UTF8; StreamReader fwdresponsestream = new StreamReader(fwdrsp.GetResponseStream(), encoding); fwdresponsestr = fwdresponsestream.ReadToEnd(); fwdresponsecontenttype = fwdrsp.ContentType; diff --git a/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs b/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs index d4bba10..b6021a9 100644 --- a/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs +++ b/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs @@ -539,7 +539,7 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator { XmlSerializer xs = new XmlSerializer(typeof(Copse)); - using (XmlTextWriter writer = new XmlTextWriter(fileName, System.Text.Encoding.UTF8)) + using (XmlTextWriter writer = new XmlTextWriter(fileName, Util.UTF8)) { writer.Formatting = Formatting.Indented; xs.Serialize(writer, obj); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index ba42678..264d585 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7064,7 +7064,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api try { byte[] encData_byte = new byte[str.Length]; - encData_byte = Encoding.UTF8.GetBytes(str); + encData_byte = Util.UTF8.GetBytes(str); string encodedData = Convert.ToBase64String(encData_byte); return encodedData; } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 726b37a..f80dd51 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -1457,7 +1457,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api notecardData = "Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length " + textLength.ToString() + "\n" + notecardData + "}\n"; - asset.Data = Encoding.UTF8.GetBytes(notecardData); + asset.Data = Util.UTF8.GetBytes(notecardData); World.AssetService.Store(asset); // Create Task Entry -- cgit v1.1