From 2a7520939d33feb2bfa797a784d83fa6384440d0 Mon Sep 17 00:00:00 2001 From: morkt Date: Fri, 7 Nov 2014 17:11:11 +0400 Subject: [PATCH] use Buffer.BlockCopy instead of Array.Copy. --- ArcFormats/ArcNPA.cs | 2 +- ArcFormats/ArcRPA.cs | 2 +- ArcFormats/ArcWILL.cs | 4 ++-- ArcFormats/ImageDRG.cs | 6 +++--- ArcFormats/KogadoCocotte.cs | 4 ++-- ArcFormats/Properties/AssemblyInfo.cs | 4 ++-- GameRes/ArcView.cs | 4 +--- GameRes/Utility.cs | 2 +- 8 files changed, 13 insertions(+), 15 deletions(-) diff --git a/ArcFormats/ArcNPA.cs b/ArcFormats/ArcNPA.cs index 2e396fa8..92b5bc11 100644 --- a/ArcFormats/ArcNPA.cs +++ b/ArcFormats/ArcNPA.cs @@ -700,7 +700,7 @@ namespace GameRes.Formats.NitroPlus if (position >= m_encrypted_length) return m_stream.Read (buffer, offset, count); int read = Math.Min (m_encrypted_length - (int)position, count); - Array.Copy (m_encrypted.Value, (int)position, buffer, offset, read); + Buffer.BlockCopy (m_encrypted.Value, (int)position, buffer, offset, read); m_stream.Seek (read, SeekOrigin.Current); if (read < count) { diff --git a/ArcFormats/ArcRPA.cs b/ArcFormats/ArcRPA.cs index d1ce7eb6..3be446c6 100644 --- a/ArcFormats/ArcRPA.cs +++ b/ArcFormats/ArcRPA.cs @@ -893,7 +893,7 @@ namespace GameRes.Formats.RenPy if (m_position < m_header.Length) { int header_count = Math.Min (count, m_header.Length - (int)m_position); - Array.Copy (m_header, (int)m_position, buffer, offset, header_count); + Buffer.BlockCopy (m_header, (int)m_position, buffer, offset, header_count); m_position += header_count; read += header_count; offset += header_count; diff --git a/ArcFormats/ArcWILL.cs b/ArcFormats/ArcWILL.cs index 8af29b62..91a9192c 100644 --- a/ArcFormats/ArcWILL.cs +++ b/ArcFormats/ArcWILL.cs @@ -201,7 +201,7 @@ namespace GameRes.Formats.Will header.Write (file_table.Count); foreach (var ext in file_table) { - Array.Copy (ext.Value.Extension, buffer, ext.Value.Extension.Length); + Buffer.BlockCopy (ext.Value.Extension, 0, buffer, 0, ext.Value.Extension.Length); for (int i = ext.Value.Extension.Length; i < 4; ++i) buffer[i] = 0; header.Write (buffer, 0, 4); @@ -212,7 +212,7 @@ namespace GameRes.Formats.Will { foreach (var entry in ext.Value.Files) { - Array.Copy (entry.RawName, buffer, entry.RawName.Length); + Buffer.BlockCopy (entry.RawName, 0, buffer, 0, entry.RawName.Length); for (int i = entry.RawName.Length; i < buffer.Length; ++i) buffer[i] = 0; header.Write (buffer); diff --git a/ArcFormats/ImageDRG.cs b/ArcFormats/ImageDRG.cs index ea4533f8..faf81442 100644 --- a/ArcFormats/ImageDRG.cs +++ b/ArcFormats/ImageDRG.cs @@ -142,7 +142,7 @@ namespace GameRes.Formats.DRS return null; for (int i = 0; i < count; ++i) { - Array.Copy (output, src_offset, output, out_pos, 3); + Buffer.BlockCopy (output, src_offset, output, out_pos, 3); out_pos += 3; } pixel_count -= count * 3; @@ -174,7 +174,7 @@ namespace GameRes.Formats.DRS src_offset = out_pos - 3 * input.ReadByte (); if (count > pixel_count || src_offset < 0 || src_offset == out_pos) return null; - Array.Copy (output, src_offset, output, out_pos, count); + Buffer.BlockCopy (output, src_offset, output, out_pos, count); out_pos += count; pixel_count -= count; break; @@ -186,7 +186,7 @@ namespace GameRes.Formats.DRS src_offset = out_pos - 3 * (off_hi << 8 | off_lo); if (count > pixel_count || src_offset < 0 || src_offset == out_pos) return null; - Array.Copy (output, src_offset, output, out_pos, count); + Buffer.BlockCopy (output, src_offset, output, out_pos, count); out_pos += count; pixel_count -= count; break; diff --git a/ArcFormats/KogadoCocotte.cs b/ArcFormats/KogadoCocotte.cs index 0336c9d6..609a3c69 100644 --- a/ArcFormats/KogadoCocotte.cs +++ b/ArcFormats/KogadoCocotte.cs @@ -600,7 +600,7 @@ namespace GameRes.Formats.Kogado n++; if (n > 0) { - Array.Copy (m_MTFTable, 0, m_MTFTable, 1, n); + Buffer.BlockCopy (m_MTFTable, 0, m_MTFTable, 1, n); m_MTFTable[0] = c; } dest[i] = n; @@ -616,7 +616,7 @@ namespace GameRes.Formats.Kogado byte c = m_MTFTable[n]; if (n > 0) { - Array.Copy (m_MTFTable, 0, m_MTFTable, 1, n); + Buffer.BlockCopy (m_MTFTable, 0, m_MTFTable, 1, n); m_MTFTable[0] = c; } dest[i] = c; diff --git a/ArcFormats/Properties/AssemblyInfo.cs b/ArcFormats/Properties/AssemblyInfo.cs index 5600245c..82d0f281 100644 --- a/ArcFormats/Properties/AssemblyInfo.cs +++ b/ArcFormats/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion ("1.0.3.22")] -[assembly: AssemblyFileVersion ("1.0.3.22")] +[assembly: AssemblyVersion ("1.0.3.23")] +[assembly: AssemblyFileVersion ("1.0.3.23")] diff --git a/GameRes/ArcView.cs b/GameRes/ArcView.cs index 933920f6..5a8d3ded 100644 --- a/GameRes/ArcView.cs +++ b/GameRes/ArcView.cs @@ -56,9 +56,7 @@ namespace GameRes break; if (buffer.Length == size) { - byte[] new_buffer = new byte[checked(size/2*3)]; - Array.Copy (buffer, new_buffer, size); - buffer = new_buffer; + Array.Resize (ref buffer, checked(size/2*3)); } buffer[size++] = (byte)b; } diff --git a/GameRes/Utility.cs b/GameRes/Utility.cs index 072dea93..6f9dc9e5 100644 --- a/GameRes/Utility.cs +++ b/GameRes/Utility.cs @@ -77,7 +77,7 @@ namespace GameRes.Utility { if (preceding > count) preceding = count; - System.Array.Copy (data, src, data, dst, preceding); + System.Buffer.BlockCopy (data, src, data, dst, preceding); src = dst; dst += preceding; count -= preceding;