Skip to content

Commit 1758c8d

Browse files
committed
fix
1 parent 99f211a commit 1758c8d

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

csharp/ToolGood.Algorithm/LitJson/JsonData.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ internal sealed class JsonData : IJsonWrapper, IEnumerable
2020

2121
#region Properties
2222

23-
public int Count { get { return EnsureCollection().Count; } }
23+
public int Count { get {
24+
if (type == JsonType.Array) return inst_array.Count;
25+
return inst_object.Count;
26+
} }
2427
public bool IsArray { get { return type == JsonType.Array; } }
2528
public bool IsBoolean { get { return type == JsonType.Boolean; } }
2629
public bool IsDouble { get { return type == JsonType.Double; } }
@@ -34,7 +37,7 @@ internal sealed class JsonData : IJsonWrapper, IEnumerable
3437

3538
public JsonData this[string prop_name] {
3639
get {
37-
EnsureDictionary();
40+
//EnsureDictionary();
3841
if (inst_object.TryGetValue(prop_name, out JsonData data)) {
3942
return data;
4043
}
@@ -44,8 +47,6 @@ public JsonData this[string prop_name] {
4447

4548
public JsonData this[int index] {
4649
get {
47-
EnsureCollection();
48-
4950
if (type == JsonType.Array)
5051
return inst_array[index];
5152
return null;
@@ -105,12 +106,6 @@ void IJsonWrapper.Set(string key, IJsonWrapper val)
105106

106107
#region Private Methods
107108

108-
private ICollection EnsureCollection()
109-
{
110-
if (type == JsonType.Array) return (ICollection)inst_array;
111-
return (ICollection)inst_object;
112-
}
113-
114109
private Dictionary<string, JsonData> EnsureDictionary()
115110
{
116111
if (type == JsonType.Object) return inst_object;

0 commit comments

Comments
 (0)