-Performance
This commit is contained in:
@@ -39,45 +39,39 @@ namespace Newtonsoft.Json
|
||||
internal struct JsonPosition
|
||||
{
|
||||
internal JsonContainerType Type;
|
||||
internal int? Position;
|
||||
internal int Position;
|
||||
internal string PropertyName;
|
||||
internal bool HasIndex;
|
||||
|
||||
public JsonPosition(JsonContainerType type)
|
||||
{
|
||||
Type = type;
|
||||
HasIndex = TypeHasIndex(type);
|
||||
Position = -1;
|
||||
PropertyName = null;
|
||||
}
|
||||
|
||||
internal void WriteTo(StringBuilder sb)
|
||||
{
|
||||
switch (Type)
|
||||
{
|
||||
case JsonContainerType.Object:
|
||||
if (PropertyName != null)
|
||||
{
|
||||
if (sb.Length > 0)
|
||||
sb.Append(".");
|
||||
sb.Append(PropertyName);
|
||||
}
|
||||
if (sb.Length > 0)
|
||||
sb.Append(".");
|
||||
sb.Append(PropertyName);
|
||||
break;
|
||||
case JsonContainerType.Array:
|
||||
case JsonContainerType.Constructor:
|
||||
if (Position != null)
|
||||
{
|
||||
sb.Append("[");
|
||||
sb.Append(Position);
|
||||
sb.Append("]");
|
||||
}
|
||||
sb.Append("[");
|
||||
sb.Append(Position);
|
||||
sb.Append("]");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool InsideContainer()
|
||||
internal static bool TypeHasIndex(JsonContainerType type)
|
||||
{
|
||||
switch (Type)
|
||||
{
|
||||
case JsonContainerType.Object:
|
||||
return (PropertyName != null);
|
||||
case JsonContainerType.Array:
|
||||
case JsonContainerType.Constructor:
|
||||
return (Position != null);
|
||||
}
|
||||
|
||||
return false;
|
||||
return (type == JsonContainerType.Array || type == JsonContainerType.Constructor);
|
||||
}
|
||||
|
||||
internal static string BuildPath(IEnumerable<JsonPosition> positions)
|
||||
|
||||
Reference in New Issue
Block a user