aboutsummaryrefslogtreecommitdiff
path: root/src/ProtocolBuffers/ByteArray.cs
diff options
context:
space:
mode:
authorcsharptest <roger@csharptest.net>2011-07-14 13:06:22 -0500
committerrogerk <devnull@localhost>2011-07-14 13:06:22 -0500
commit74c5e0c3762939fbf5988daf6f97c5d9c97ef4f5 (patch)
tree642a1a002907d3291c88e7933cfda87a6704beee /src/ProtocolBuffers/ByteArray.cs
parentafff2c655c1d39b8f6cd7756c190a559d15134d1 (diff)
downloadprotobuf-74c5e0c3762939fbf5988daf6f97c5d9c97ef4f5.tar.gz
protobuf-74c5e0c3762939fbf5988daf6f97c5d9c97ef4f5.tar.bz2
protobuf-74c5e0c3762939fbf5988daf6f97c5d9c97ef4f5.zip
Reformatted to include braces
Diffstat (limited to 'src/ProtocolBuffers/ByteArray.cs')
-rw-r--r--src/ProtocolBuffers/ByteArray.cs17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/ProtocolBuffers/ByteArray.cs b/src/ProtocolBuffers/ByteArray.cs
index 7c92449c..3c51b7b0 100644
--- a/src/ProtocolBuffers/ByteArray.cs
+++ b/src/ProtocolBuffers/ByteArray.cs
@@ -34,27 +34,35 @@
#endregion
+using System;
+
namespace Google.ProtocolBuffers
{
/// <summary>
/// Provides a utility routine to copy small arrays much more quickly than Buffer.BlockCopy
/// </summary>
- static class ByteArray
+ internal static class ByteArray
{
/// <summary>
/// The threshold above which you should use Buffer.BlockCopy rather than ByteArray.Copy
/// </summary>
- const int CopyThreshold = 12;
+ private const int CopyThreshold = 12;
+
/// <summary>
/// Determines which copy routine to use based on the number of bytes to be copied.
/// </summary>
public static void Copy(byte[] src, int srcOffset, byte[] dst, int dstOffset, int count)
{
if (count > CopyThreshold)
- global::System.Buffer.BlockCopy(src, srcOffset, dst, dstOffset, count);
+ {
+ Buffer.BlockCopy(src, srcOffset, dst, dstOffset, count);
+ }
else
+ {
ByteCopy(src, srcOffset, dst, dstOffset, count);
+ }
}
+
/// <summary>
/// Copy the bytes provided with a for loop, faster when there are only a few bytes to copy
/// </summary>
@@ -62,8 +70,11 @@ namespace Google.ProtocolBuffers
{
int stop = srcOffset + count;
for (int i = srcOffset; i < stop; i++)
+ {
dst[dstOffset++] = src[i];
+ }
}
+
/// <summary>
/// Reverses the order of bytes in the array
/// </summary>