Skip to content

Commit

Permalink
improved reference compute performance. issue #859
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Oct 20, 2016
1 parent 3eaeea8 commit 94d4c97
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/main/java/com/alibaba/fastjson/parser/ParseContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class ParseContext {
public final ParseContext parent;
public final Object fieldName;
public Type type;
private transient String path;

public ParseContext(ParseContext parent, Object object, Object fieldName){
this.parent = parent;
Expand All @@ -16,15 +17,18 @@ public ParseContext(ParseContext parent, Object object, Object fieldName){
}

public String toString() {
if (parent == null) {
return "$";
} else {
if (fieldName instanceof Integer) {
return parent.toString() + "[" + fieldName + "]";
if (path == null) {
if (parent == null) {
path = "$";
} else {
return parent.toString() + "." + fieldName;
if (fieldName instanceof Integer) {
path = parent.toString() + "[" + fieldName + "]";
} else {
path = parent.toString() + "." + fieldName;
}
}

}

return path;
}
}

0 comments on commit 94d4c97

Please sign in to comment.