diff Implab/Formats/Json/JsonReader.cs @ 236:302ca905c19e v2

JsonReader optimizations
author cin
date Tue, 21 Nov 2017 14:57:58 +0300
parents 3e26338eb977
children
line wrap: on
line diff
--- a/Implab/Formats/Json/JsonReader.cs	Thu Oct 05 09:24:49 2017 +0300
+++ b/Implab/Formats/Json/JsonReader.cs	Tue Nov 21 14:57:58 2017 +0300
@@ -48,7 +48,7 @@
 
             public bool Move(JsonTokenType token) {
                 var next = m_dfa[m_state, (int)token];
-                if (next == AutomatonConst.UNREACHABLE_STATE)
+                if (next == AutomatonConst.UnreachableState)
                     return false;
                 m_state = next;
                 return true;
@@ -116,7 +116,7 @@
         MemberContext m_memberContext = MemberContext.MemberValue;
 
         JsonElementType m_elementType;
-        object m_elementValue;
+        string m_elementValue;
         string m_memberName = String.Empty;
 
         Stack<ParserContext> m_stack = new Stack<ParserContext>();
@@ -152,7 +152,7 @@
         /// <summary>
         /// Значение элемента. Только для элементов типа <see cref="JsonElementType.Value"/>, для остальных <c>null</c>
         /// </summary>
-        public object ElementValue {
+        public string ElementValue {
             get { return m_elementValue; }
         }
 
@@ -213,11 +213,11 @@
                         return true;
                     case JsonTokenType.Number:
                         m_elementType = JsonElementType.Value;
-                        m_elementValue = double.Parse(tokenValue, CultureInfo.InvariantCulture);
+                        m_elementValue = tokenValue;
                         return true;
                     case JsonTokenType.Literal:
                         m_elementType = JsonElementType.Value;
-                        m_elementValue = ParseLiteral(tokenValue);
+                        m_elementValue = tokenValue == "null" ? null : tokenValue;
                         return true;
                     case JsonTokenType.NameSeparator:
                         m_memberContext = MemberContext.MemberValue;