JSON.parse improvement. Call "LookupSymbol" rather than "NewString"
for property string tokens. Review URL: http://codereview.chromium.org/7004016 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7859 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
4cc800b3cf
commit
fcd9380eda
@ -4084,6 +4084,21 @@ Handle<String> JsonParser::GetString() {
|
||||
}
|
||||
|
||||
|
||||
Handle<String> JsonParser::GetSymbol() {
|
||||
int literal_length = scanner_.literal_length();
|
||||
if (literal_length == 0) {
|
||||
return isolate()->factory()->empty_string();
|
||||
}
|
||||
if (scanner_.is_literal_ascii()) {
|
||||
return isolate()->factory()->LookupAsciiSymbol(
|
||||
scanner_.literal_ascii_string());
|
||||
} else {
|
||||
return isolate()->factory()->LookupTwoByteSymbol(
|
||||
scanner_.literal_uc16_string());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Parse any JSON value.
|
||||
Handle<Object> JsonParser::ParseJsonValue() {
|
||||
Token::Value token = scanner_.Next();
|
||||
@ -4125,7 +4140,7 @@ Handle<Object> JsonParser::ParseJsonObject() {
|
||||
if (scanner_.Next() != Token::STRING) {
|
||||
return ReportUnexpectedToken();
|
||||
}
|
||||
Handle<String> key = GetString();
|
||||
Handle<String> key = GetSymbol();
|
||||
if (scanner_.Next() != Token::COLON) {
|
||||
return ReportUnexpectedToken();
|
||||
}
|
||||
|
@ -814,6 +814,8 @@ class JsonParser BASE_EMBEDDED {
|
||||
Handle<Object> ReportUnexpectedToken() { return Handle<Object>::null(); }
|
||||
// Converts the currently parsed literal to a JavaScript String.
|
||||
Handle<String> GetString();
|
||||
// Converts the currently parsed literal to a JavaScript Symbol String.
|
||||
Handle<String> GetSymbol();
|
||||
|
||||
Isolate* isolate_;
|
||||
JsonScanner scanner_;
|
||||
|
Loading…
Reference in New Issue
Block a user