use Buffer.BlockCopy instead of Array.Copy.

This commit is contained in:
morkt 2014-11-07 17:11:11 +04:00
parent 3a2be63bf3
commit 2a7520939d
8 changed files with 13 additions and 15 deletions

View File

@ -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)
{

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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")]

View File

@ -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;
}

View File

@ -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;