Skip to content

Commit

Permalink
Remove unused internal method
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesNK committed Nov 5, 2020
1 parent b29a88d commit 99bda0d
Showing 1 changed file with 2 additions and 21 deletions.
23 changes: 2 additions & 21 deletions csharp/src/Google.Protobuf/ByteString.cs
Expand Up @@ -58,15 +58,15 @@ public sealed class ByteString : IEnumerable<byte>, IEquatable<ByteString>
private readonly ReadOnlyMemory<byte> bytes;

/// <summary>
/// Internal use only. Ensure that the provided array is not mutated and belongs to this instance.
/// Internal use only. Ensure that the provided memory is not mutated and belongs to this instance.
/// </summary>
internal static ByteString AttachBytes(ReadOnlyMemory<byte> bytes)
{
return new ByteString(bytes);
}

/// <summary>
/// Constructs a new ByteString from the given byte array. The array is
/// Constructs a new ByteString from the given memory. The memory is
/// *not* copied, and must not be modified after this constructor is called.
/// </summary>
private ByteString(ReadOnlyMemory<byte> bytes)
Expand Down Expand Up @@ -312,7 +312,6 @@ IEnumerator IEnumerable.GetEnumerator()
public CodedInputStream CreateCodedInput()
{
// We trust CodedInputStream not to reveal the provided byte array or modify it

if (MemoryMarshal.TryGetArray(bytes, out ArraySegment<byte> segment) && segment.Count == bytes.Length)
{
// Fast path. ByteString was created with a complete array.
Expand Down Expand Up @@ -396,24 +395,6 @@ public bool Equals(ByteString other)
return this == other;
}

/// <summary>
/// Used internally by CodedOutputStream to avoid creating a copy for the write
/// </summary>
internal void WriteRawBytesTo(CodedOutputStream outputStream)
{
if (MemoryMarshal.TryGetArray(bytes, out ArraySegment<byte> segment))
{
// Fast path. ByteString was created with an array, so pass the underlying array.
outputStream.WriteRawBytes(segment.Array, segment.Offset, segment.Count);
}
else
{
// Slow path. BytesString is not an array. Convert memory and pass result to WriteRawBytes.
// TODO: Consider CodedOutputStream.WriteRawBytes(ReadOnlyMemory<bytes>) overload.
outputStream.WriteRawBytes(bytes.ToArray());
}
}

/// <summary>
/// Copies the entire byte array to the destination array provided at the offset specified.
/// </summary>
Expand Down

0 comments on commit 99bda0d

Please sign in to comment.