diff options
author | Jon Skeet <jonskeet@google.com> | 2015-06-25 12:08:18 +0100 |
---|---|---|
committer | Jon Skeet <jonskeet@google.com> | 2015-06-25 12:08:18 +0100 |
commit | df44ae4413109a7c3ce9f27fb7ae02f0414c29d9 (patch) | |
tree | 95554e77d4c4847a278fa645206be2054ca864c2 /csharp/src/ProtocolBuffers/CodedInputStream.cs | |
parent | e36e601a394e96759a9ccf0eda97c0451c49c2cc (diff) | |
download | protobuf-df44ae4413109a7c3ce9f27fb7ae02f0414c29d9.tar.gz protobuf-df44ae4413109a7c3ce9f27fb7ae02f0414c29d9.tar.bz2 protobuf-df44ae4413109a7c3ce9f27fb7ae02f0414c29d9.zip |
More map tests, and various production code improvements.
Generated code in next commit.
Diffstat (limited to 'csharp/src/ProtocolBuffers/CodedInputStream.cs')
-rw-r--r-- | csharp/src/ProtocolBuffers/CodedInputStream.cs | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/csharp/src/ProtocolBuffers/CodedInputStream.cs b/csharp/src/ProtocolBuffers/CodedInputStream.cs index 905cdb9d..dab3e5e3 100644 --- a/csharp/src/ProtocolBuffers/CodedInputStream.cs +++ b/csharp/src/ProtocolBuffers/CodedInputStream.cs @@ -456,14 +456,16 @@ namespace Google.Protobuf }
/// <summary>
- /// Returns true if the next tag is also part of the same unpacked array.
+ /// Peeks at the next tag in the stream. If it matches <paramref name="tag"/>,
+ /// the tag is consumed and the method returns <c>true</c>; otherwise, the
+ /// stream is left in the original position and the method returns <c>false</c>.
/// </summary>
- private bool ContinueArray(uint currentTag)
+ public bool MaybeConsumeTag(uint tag)
{
uint next;
if (PeekNextTag(out next))
{
- if (next == currentTag)
+ if (next == tag)
{
hasNextTag = false;
return true;
@@ -486,17 +488,7 @@ namespace Google.Protobuf }
return true;
}
-
- uint next;
- if (PeekNextTag(out next))
- {
- if (next == currentTag)
- {
- hasNextTag = false;
- return true;
- }
- }
- return false;
+ return MaybeConsumeTag(currentTag);
}
/// <summary>
@@ -512,7 +504,7 @@ namespace Google.Protobuf do
{
list.Add(ReadString());
- } while (ContinueArray(fieldTag));
+ } while (MaybeConsumeTag(fieldTag));
}
public void ReadBytesArray(ICollection<ByteString> list)
@@ -521,7 +513,7 @@ namespace Google.Protobuf do
{
list.Add(ReadBytes());
- } while (ContinueArray(fieldTag));
+ } while (MaybeConsumeTag(fieldTag));
}
public void ReadBoolArray(ICollection<bool> list)
@@ -729,7 +721,7 @@ namespace Google.Protobuf do
{
list.Add((T)(object) ReadEnum());
- } while (ContinueArray(fieldTag));
+ } while (MaybeConsumeTag(fieldTag));
}
}
@@ -742,7 +734,7 @@ namespace Google.Protobuf T message = messageParser.CreateTemplate();
ReadMessage(message);
list.Add(message);
- } while (ContinueArray(fieldTag));
+ } while (MaybeConsumeTag(fieldTag));
}
#endregion
|