aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Serialization/TarArchiveReader.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-07-11 22:54:22 +0100
committerJustin Clark-Casey (justincc)2012-07-11 22:54:22 +0100
commit916e3bf886ee622e2f18d6eb74f90fee8c630471 (patch)
tree69f9a6d2a7f7041966400f56f46c198f2cc06158 /OpenSim/Framework/Serialization/TarArchiveReader.cs
parentFix build break for windows with missing package for IScriptEngine in prebuil... (diff)
downloadopensim-SC_OLD-916e3bf886ee622e2f18d6eb74f90fee8c630471.zip
opensim-SC_OLD-916e3bf886ee622e2f18d6eb74f90fee8c630471.tar.gz
opensim-SC_OLD-916e3bf886ee622e2f18d6eb74f90fee8c630471.tar.bz2
opensim-SC_OLD-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/Framework/Serialization/TarArchiveReader.cs')
-rw-r--r--OpenSim/Framework/Serialization/TarArchiveReader.cs8
1 files changed, 3 insertions, 5 deletions
diff --git a/OpenSim/Framework/Serialization/TarArchiveReader.cs b/OpenSim/Framework/Serialization/TarArchiveReader.cs
index 77c29f8..339a37a 100644
--- a/OpenSim/Framework/Serialization/TarArchiveReader.cs
+++ b/OpenSim/Framework/Serialization/TarArchiveReader.cs
@@ -53,8 +53,6 @@ namespace OpenSim.Framework.Serialization
53 TYPE_CONTIGUOUS_FILE = 8, 53 TYPE_CONTIGUOUS_FILE = 8,
54 } 54 }
55 55
56 protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding();
57
58 /// <summary> 56 /// <summary>
59 /// Binary reader for the underlying stream 57 /// Binary reader for the underlying stream
60 /// </summary> 58 /// </summary>
@@ -120,13 +118,13 @@ namespace OpenSim.Framework.Serialization
120 if (header[156] == (byte)'L') 118 if (header[156] == (byte)'L')
121 { 119 {
122 int longNameLength = ConvertOctalBytesToDecimal(header, 124, 11); 120 int longNameLength = ConvertOctalBytesToDecimal(header, 124, 11);
123 tarHeader.FilePath = m_asciiEncoding.GetString(ReadData(longNameLength)); 121 tarHeader.FilePath = Encoding.ASCII.GetString(ReadData(longNameLength));
124 //m_log.DebugFormat("[TAR ARCHIVE READER]: Got long file name {0}", tarHeader.FilePath); 122 //m_log.DebugFormat("[TAR ARCHIVE READER]: Got long file name {0}", tarHeader.FilePath);
125 header = m_br.ReadBytes(512); 123 header = m_br.ReadBytes(512);
126 } 124 }
127 else 125 else
128 { 126 {
129 tarHeader.FilePath = m_asciiEncoding.GetString(header, 0, 100); 127 tarHeader.FilePath = Encoding.ASCII.GetString(header, 0, 100);
130 tarHeader.FilePath = tarHeader.FilePath.Trim(m_nullCharArray); 128 tarHeader.FilePath = tarHeader.FilePath.Trim(m_nullCharArray);
131 //m_log.DebugFormat("[TAR ARCHIVE READER]: Got short file name {0}", tarHeader.FilePath); 129 //m_log.DebugFormat("[TAR ARCHIVE READER]: Got short file name {0}", tarHeader.FilePath);
132 } 130 }
@@ -205,7 +203,7 @@ namespace OpenSim.Framework.Serialization
205 { 203 {
206 // Trim leading white space: ancient tars do that instead 204 // Trim leading white space: ancient tars do that instead
207 // of leading 0s :-( don't ask. really. 205 // of leading 0s :-( don't ask. really.
208 string oString = m_asciiEncoding.GetString(bytes, startIndex, count).TrimStart(m_spaceCharArray); 206 string oString = Encoding.ASCII.GetString(bytes, startIndex, count).TrimStart(m_spaceCharArray);
209 207
210 int d = 0; 208 int d = 0;
211 209