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/Shared/Instance | |
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/Shared/Instance')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 19 |
1 files changed, 8 insertions, 11 deletions
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 | } |