From 6a942735497e185bb5fc0a3d1e8698726dc754c9 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Wed, 4 Nov 2015 09:09:14 +0000 Subject: Move the creation of the "fields by JSON name" dictionary to the descriptor. --- csharp/src/Google.Protobuf/JsonParser.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'csharp/src/Google.Protobuf/JsonParser.cs') diff --git a/csharp/src/Google.Protobuf/JsonParser.cs b/csharp/src/Google.Protobuf/JsonParser.cs index 6d2638d9..9710e675 100644 --- a/csharp/src/Google.Protobuf/JsonParser.cs +++ b/csharp/src/Google.Protobuf/JsonParser.cs @@ -37,7 +37,6 @@ using System.Collections; using System.Collections.Generic; using System.Globalization; using System.IO; -using System.Linq; using System.Text; using System.Text.RegularExpressions; @@ -164,11 +163,7 @@ namespace Google.Protobuf throw new InvalidProtocolBufferException("Expected an object"); } var descriptor = message.Descriptor; - // TODO: Make this more efficient, e.g. by building it once in the descriptor. - // Additionally, we need to consider whether to parse field names in their original proto form, - // and any overrides in the descriptor. But yes, all of this should be in the descriptor somehow... - // the descriptor can expose the dictionary. - var jsonFieldMap = descriptor.Fields.InDeclarationOrder().ToDictionary(field => JsonFormatter.ToCamelCase(field.Name)); + var jsonFieldMap = descriptor.Fields.ByJsonName(); while (true) { token = tokenizer.Next(); -- cgit v1.2.3