aboutsummaryrefslogtreecommitdiff
path: root/src/ProtocolBuffers/CodedInputStream.cs
diff options
context:
space:
mode:
authorcsharptest <roger@csharptest.net>2011-06-08 15:50:58 -0500
committerrogerk <devnull@localhost>2011-06-08 15:50:58 -0500
commit2772dfe8a1eae7c942bb50d84bda3f45b5d7b683 (patch)
tree0171c98d38d419780317398595c511810a19e203 /src/ProtocolBuffers/CodedInputStream.cs
parent0e2d144eb6e08f841ed4476cfff23ad462bbbcd9 (diff)
downloadprotobuf-2772dfe8a1eae7c942bb50d84bda3f45b5d7b683.tar.gz
protobuf-2772dfe8a1eae7c942bb50d84bda3f45b5d7b683.tar.bz2
protobuf-2772dfe8a1eae7c942bb50d84bda3f45b5d7b683.zip
Performance fix for float/double write bytes. Performance fix, do not use Array.Copy.
Diffstat (limited to 'src/ProtocolBuffers/CodedInputStream.cs')
-rw-r--r--src/ProtocolBuffers/CodedInputStream.cs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/ProtocolBuffers/CodedInputStream.cs b/src/ProtocolBuffers/CodedInputStream.cs
index 74fa9475..4f9bdc23 100644
--- a/src/ProtocolBuffers/CodedInputStream.cs
+++ b/src/ProtocolBuffers/CodedInputStream.cs
@@ -1225,7 +1225,7 @@ namespace Google.ProtocolBuffers
{
// We have all the bytes we need already.
byte[] bytes = new byte[size];
- Array.Copy(buffer, bufferPos, bytes, 0, size);
+ Bytes.Copy(buffer, bufferPos, bytes, 0, size);
bufferPos += size;
return bytes;
}
@@ -1237,7 +1237,7 @@ namespace Google.ProtocolBuffers
// First copy what we have.
byte[] bytes = new byte[size];
int pos = bufferSize - bufferPos;
- Array.Copy(buffer, bufferPos, bytes, 0, pos);
+ Bytes.Copy(buffer, bufferPos, bytes, 0, pos);
bufferPos = bufferSize;
// We want to use RefillBuffer() and then copy from the buffer into our
@@ -1247,13 +1247,13 @@ namespace Google.ProtocolBuffers
while (size - pos > bufferSize)
{
- Array.Copy(buffer, 0, bytes, pos, bufferSize);
+ Buffer.BlockCopy(buffer, 0, bytes, pos, bufferSize);
pos += bufferSize;
bufferPos = bufferSize;
RefillBuffer(true);
}
- Array.Copy(buffer, 0, bytes, pos, size - pos);
+ Bytes.Copy(buffer, 0, bytes, pos, size - pos);
bufferPos = size - pos;
return bytes;
@@ -1305,12 +1305,12 @@ namespace Google.ProtocolBuffers
// Start by copying the leftover bytes from this.buffer.
int newPos = originalBufferSize - originalBufferPos;
- Array.Copy(buffer, originalBufferPos, bytes, 0, newPos);
+ Bytes.Copy(buffer, originalBufferPos, bytes, 0, newPos);
// And now all the chunks.
foreach (byte[] chunk in chunks)
{
- Array.Copy(chunk, 0, bytes, newPos, chunk.Length);
+ Buffer.BlockCopy(chunk, 0, bytes, newPos, chunk.Length);
newPos += chunk.Length;
}