diff options
author | Justin Clark-Casey (justincc) | 2012-07-11 22:54:22 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-07-11 22:54:22 +0100 |
commit | 916e3bf886ee622e2f18d6eb74f90fee8c630471 (patch) | |
tree | 69f9a6d2a7f7041966400f56f46c198f2cc06158 /OpenSim/Region/ScriptEngine | |
parent | Fix build break for windows with missing package for IScriptEngine in prebuil... (diff) | |
download | opensim-SC-916e3bf886ee622e2f18d6eb74f90fee8c630471.zip opensim-SC-916e3bf886ee622e2f18d6eb74f90fee8c630471.tar.gz opensim-SC-916e3bf886ee622e2f18d6eb74f90fee8c630471.tar.bz2 opensim-SC-916e3bf886ee622e2f18d6eb74f90fee8c630471.tar.xz |
Where possible, use the system Encoding.ASCII and Encoding.UTF8 rather than constructing fresh copies.
The encodings are thread-safe and already used in such a manner in other places.
This isn't done where Byte Order Mark output is suppressed, since Encoding.UTF8 is constructed to output the BOM.
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
5 files changed, 15 insertions, 25 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 0a25454..0ebcd8d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -10536,9 +10536,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10536 | return; | 10536 | return; |
10537 | } | 10537 | } |
10538 | 10538 | ||
10539 | System.Text.UTF8Encoding enc = | 10539 | string data = Encoding.UTF8.GetString(a.Data); |
10540 | new System.Text.UTF8Encoding(); | ||
10541 | string data = enc.GetString(a.Data); | ||
10542 | //m_log.Debug(data); | 10540 | //m_log.Debug(data); |
10543 | NotecardCache.Cache(id, data); | 10541 | NotecardCache.Cache(id, data); |
10544 | AsyncCommands. | 10542 | AsyncCommands. |
@@ -10591,9 +10589,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10591 | return; | 10589 | return; |
10592 | } | 10590 | } |
10593 | 10591 | ||
10594 | System.Text.UTF8Encoding enc = | 10592 | string data = Encoding.UTF8.GetString(a.Data); |
10595 | new System.Text.UTF8Encoding(); | ||
10596 | string data = enc.GetString(a.Data); | ||
10597 | //m_log.Debug(data); | 10593 | //m_log.Debug(data); |
10598 | NotecardCache.Cache(id, data); | 10594 | NotecardCache.Cache(id, data); |
10599 | AsyncCommands.DataserverPlugin.DataserverReply(id.ToString(), | 10595 | AsyncCommands.DataserverPlugin.DataserverReply(id.ToString(), |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index e90f577..cfa08c2 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -1811,8 +1811,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1811 | if (a == null) | 1811 | if (a == null) |
1812 | return UUID.Zero; | 1812 | return UUID.Zero; |
1813 | 1813 | ||
1814 | System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); | 1814 | string data = Encoding.UTF8.GetString(a.Data); |
1815 | string data = enc.GetString(a.Data); | ||
1816 | NotecardCache.Cache(assetID, data); | 1815 | NotecardCache.Cache(assetID, data); |
1817 | }; | 1816 | }; |
1818 | 1817 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs index 8f2ec49..17a0d69 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs | |||
@@ -31,6 +31,7 @@ using System.Collections.Generic; | |||
31 | using System.Globalization; | 31 | using System.Globalization; |
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using System.IO; | 33 | using System.IO; |
34 | using System.Text; | ||
34 | using Microsoft.CSharp; | 35 | using Microsoft.CSharp; |
35 | //using Microsoft.JScript; | 36 | //using Microsoft.JScript; |
36 | using Microsoft.VisualBasic; | 37 | using Microsoft.VisualBasic; |
@@ -711,9 +712,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
711 | // | 712 | // |
712 | string filetext = System.Convert.ToBase64String(data); | 713 | string filetext = System.Convert.ToBase64String(data); |
713 | 714 | ||
714 | System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); | 715 | Byte[] buf = Encoding.ASCII.GetBytes(filetext); |
715 | |||
716 | Byte[] buf = enc.GetBytes(filetext); | ||
717 | 716 | ||
718 | FileStream sfs = File.Create(assembly + ".text"); | 717 | FileStream sfs = File.Create(assembly + ".text"); |
719 | sfs.Write(buf, 0, buf.Length); | 718 | sfs.Write(buf, 0, buf.Length); |
@@ -804,8 +803,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
804 | mapstring += String.Format("{0},{1},{2},{3}\n", k.Key, k.Value, v.Key, v.Value); | 803 | mapstring += String.Format("{0},{1},{2},{3}\n", k.Key, k.Value, v.Key, v.Value); |
805 | } | 804 | } |
806 | 805 | ||
807 | System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); | 806 | Byte[] mapbytes = Encoding.ASCII.GetBytes(mapstring); |
808 | Byte[] mapbytes = enc.GetBytes(mapstring); | ||
809 | FileStream mfs = File.Create(filename); | 807 | FileStream mfs = File.Create(filename); |
810 | mfs.Write(mapbytes, 0, mapbytes.Length); | 808 | mfs.Write(mapbytes, 0, mapbytes.Length); |
811 | mfs.Close(); | 809 | mfs.Close(); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 306090e..1c0cac7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -26,15 +26,16 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Globalization; | ||
29 | using System.IO; | 32 | using System.IO; |
33 | using System.Reflection; | ||
30 | using System.Runtime.Remoting; | 34 | using System.Runtime.Remoting; |
31 | using System.Runtime.Remoting.Lifetime; | 35 | using System.Runtime.Remoting.Lifetime; |
32 | using System.Threading; | ||
33 | using System.Collections; | ||
34 | using System.Collections.Generic; | ||
35 | using System.Security.Policy; | 36 | using System.Security.Policy; |
36 | using System.Reflection; | 37 | using System.Text; |
37 | using System.Globalization; | 38 | using System.Threading; |
38 | using System.Xml; | 39 | using System.Xml; |
39 | using OpenMetaverse; | 40 | using OpenMetaverse; |
40 | using log4net; | 41 | using log4net; |
@@ -298,13 +299,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
298 | using (FileStream fs = File.Open(savedState, | 299 | using (FileStream fs = File.Open(savedState, |
299 | FileMode.Open, FileAccess.Read, FileShare.None)) | 300 | FileMode.Open, FileAccess.Read, FileShare.None)) |
300 | { | 301 | { |
301 | System.Text.UTF8Encoding enc = | ||
302 | new System.Text.UTF8Encoding(); | ||
303 | |||
304 | Byte[] data = new Byte[size]; | 302 | Byte[] data = new Byte[size]; |
305 | fs.Read(data, 0, size); | 303 | fs.Read(data, 0, size); |
306 | 304 | ||
307 | xml = enc.GetString(data); | 305 | xml = Encoding.UTF8.GetString(data); |
308 | 306 | ||
309 | ScriptSerializer.Deserialize(xml, this); | 307 | ScriptSerializer.Deserialize(xml, this); |
310 | 308 | ||
@@ -954,8 +952,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
954 | try | 952 | try |
955 | { | 953 | { |
956 | FileStream fs = File.Create(Path.Combine(Path.GetDirectoryName(assembly), ItemID.ToString() + ".state")); | 954 | FileStream fs = File.Create(Path.Combine(Path.GetDirectoryName(assembly), ItemID.ToString() + ".state")); |
957 | System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); | 955 | Byte[] buf = (new UTF8Encoding()).GetBytes(xml); |
958 | Byte[] buf = enc.GetBytes(xml); | ||
959 | fs.Write(buf, 0, buf.Length); | 956 | fs.Write(buf, 0, buf.Length); |
960 | fs.Close(); | 957 | fs.Close(); |
961 | } | 958 | } |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index f768cf2..20fad05 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -1763,7 +1763,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1763 | tfs.Read(tdata, 0, tdata.Length); | 1763 | tfs.Read(tdata, 0, tdata.Length); |
1764 | } | 1764 | } |
1765 | 1765 | ||
1766 | assem = new System.Text.ASCIIEncoding().GetString(tdata); | 1766 | assem = Encoding.ASCII.GetString(tdata); |
1767 | } | 1767 | } |
1768 | catch (Exception e) | 1768 | catch (Exception e) |
1769 | { | 1769 | { |