diff options
author | csharptest <roger@csharptest.net> | 2011-06-02 10:52:37 -0500 |
---|---|---|
committer | rogerk <devnull@localhost> | 2011-06-02 10:52:37 -0500 |
commit | 45a93fad4d7123887d14135ee15ee3e9b0d4ca58 (patch) | |
tree | c62c6a5b4159619de112d4d60bb876d834ca4e94 /src/ProtocolBuffers/CodedOutputStream.cs | |
parent | efed509b55a1ab6d18b8ef960d799973e7e74544 (diff) | |
download | protobuf-45a93fad4d7123887d14135ee15ee3e9b0d4ca58.tar.gz protobuf-45a93fad4d7123887d14135ee15ee3e9b0d4ca58.tar.bz2 protobuf-45a93fad4d7123887d14135ee15ee3e9b0d4ca58.zip |
Optimized access to ByteString from coded io.
Diffstat (limited to 'src/ProtocolBuffers/CodedOutputStream.cs')
-rw-r--r-- | src/ProtocolBuffers/CodedOutputStream.cs | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/ProtocolBuffers/CodedOutputStream.cs b/src/ProtocolBuffers/CodedOutputStream.cs index f905b357..f30c8061 100644 --- a/src/ProtocolBuffers/CodedOutputStream.cs +++ b/src/ProtocolBuffers/CodedOutputStream.cs @@ -54,7 +54,7 @@ namespace Google.ProtocolBuffers /// methods are taken from the protocol buffer type names, not .NET types.
/// (Hence WriteFloat instead of WriteSingle, and WriteBool instead of WriteBoolean.)
/// </remarks>
- public sealed class CodedOutputStream
+ public sealed partial class CodedOutputStream
{
/// <summary>
/// The buffer size used by CreateInstance(Stream).
@@ -257,11 +257,9 @@ namespace Google.ProtocolBuffers public void WriteBytes(int fieldNumber, ByteString value)
{
- // TODO(jonskeet): Optimise this! (No need to copy the bytes twice.)
WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
- byte[] bytes = value.ToByteArray();
- WriteRawVarint32((uint) bytes.Length);
- WriteRawBytes(bytes);
+ WriteRawVarint32((uint)value.Length);
+ value.WriteTo(this);
}
[CLSCompliant(false)]
@@ -564,10 +562,8 @@ namespace Google.ProtocolBuffers public void WriteBytesNoTag(ByteString value)
{
- // TODO(jonskeet): Optimise this! (No need to copy the bytes twice.)
- byte[] bytes = value.ToByteArray();
- WriteRawVarint32((uint) bytes.Length);
- WriteRawBytes(bytes);
+ WriteRawVarint32((uint)value.Length);
+ value.WriteTo(this);
}
[CLSCompliant(false)]
|