|
@@ -38,6 +38,7 @@ using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Globalization;
|
|
using System.IO;
|
|
using System.IO;
|
|
|
|
+using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
using System.Text;
|
|
using Google.ProtocolBuffers.Descriptors;
|
|
using Google.ProtocolBuffers.Descriptors;
|
|
|
|
|
|
@@ -648,7 +649,20 @@ namespace Google.ProtocolBuffers
|
|
byte[] rawBytes = BitConverter.GetBytes(value);
|
|
byte[] rawBytes = BitConverter.GetBytes(value);
|
|
if (!BitConverter.IsLittleEndian)
|
|
if (!BitConverter.IsLittleEndian)
|
|
Array.Reverse(rawBytes);
|
|
Array.Reverse(rawBytes);
|
|
- WriteRawBytes(rawBytes, 0, 8);
|
|
|
|
|
|
+
|
|
|
|
+ if (limit - position >= 8)
|
|
|
|
+ {
|
|
|
|
+ buffer[position++] = rawBytes[0];
|
|
|
|
+ buffer[position++] = rawBytes[1];
|
|
|
|
+ buffer[position++] = rawBytes[2];
|
|
|
|
+ buffer[position++] = rawBytes[3];
|
|
|
|
+ buffer[position++] = rawBytes[4];
|
|
|
|
+ buffer[position++] = rawBytes[5];
|
|
|
|
+ buffer[position++] = rawBytes[6];
|
|
|
|
+ buffer[position++] = rawBytes[7];
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ WriteRawBytes(rawBytes, 0, 8);
|
|
#else
|
|
#else
|
|
WriteRawLittleEndian64((ulong)BitConverter.DoubleToInt64Bits(value));
|
|
WriteRawLittleEndian64((ulong)BitConverter.DoubleToInt64Bits(value));
|
|
#endif
|
|
#endif
|
|
@@ -662,7 +676,16 @@ namespace Google.ProtocolBuffers
|
|
byte[] rawBytes = BitConverter.GetBytes(value);
|
|
byte[] rawBytes = BitConverter.GetBytes(value);
|
|
if (!BitConverter.IsLittleEndian)
|
|
if (!BitConverter.IsLittleEndian)
|
|
Array.Reverse(rawBytes);
|
|
Array.Reverse(rawBytes);
|
|
- WriteRawBytes(rawBytes, 0, 4);
|
|
|
|
|
|
+
|
|
|
|
+ if (limit - position >= 4)
|
|
|
|
+ {
|
|
|
|
+ buffer[position++] = rawBytes[0];
|
|
|
|
+ buffer[position++] = rawBytes[1];
|
|
|
|
+ buffer[position++] = rawBytes[2];
|
|
|
|
+ buffer[position++] = rawBytes[3];
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ WriteRawBytes(rawBytes, 0, 4);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -985,7 +1008,7 @@ namespace Google.ProtocolBuffers
|
|
{
|
|
{
|
|
if (limit - position >= length)
|
|
if (limit - position >= length)
|
|
{
|
|
{
|
|
- Array.Copy(value, offset, buffer, position, length);
|
|
|
|
|
|
+ Bytes.Copy(value, offset, buffer, position, length);
|
|
// We have room in the current buffer.
|
|
// We have room in the current buffer.
|
|
position += length;
|
|
position += length;
|
|
}
|
|
}
|
|
@@ -994,7 +1017,7 @@ namespace Google.ProtocolBuffers
|
|
// Write extends past current buffer. Fill the rest of this buffer and
|
|
// Write extends past current buffer. Fill the rest of this buffer and
|
|
// flush.
|
|
// flush.
|
|
int bytesWritten = limit - position;
|
|
int bytesWritten = limit - position;
|
|
- Array.Copy(value, offset, buffer, position, bytesWritten);
|
|
|
|
|
|
+ Bytes.Copy(value, offset, buffer, position, bytesWritten);
|
|
offset += bytesWritten;
|
|
offset += bytesWritten;
|
|
length -= bytesWritten;
|
|
length -= bytesWritten;
|
|
position = limit;
|
|
position = limit;
|
|
@@ -1006,7 +1029,7 @@ namespace Google.ProtocolBuffers
|
|
if (length <= limit)
|
|
if (length <= limit)
|
|
{
|
|
{
|
|
// Fits in new buffer.
|
|
// Fits in new buffer.
|
|
- Array.Copy(value, offset, buffer, 0, length);
|
|
|
|
|
|
+ Bytes.Copy(value, offset, buffer, 0, length);
|
|
position = length;
|
|
position = length;
|
|
}
|
|
}
|
|
else
|
|
else
|