diff options
author | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-16 15:23:30 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-16 15:23:30 +0000 |
commit | 6e680cfca66d0461f2824ccb5128e4f9cbb20bb6 (patch) | |
tree | 8810c22ec7ab357f5cc15cc508565d2a9872dcf5 /net/test | |
parent | 97570b99a4341b1d1d6512f5d82b43c3123eb927 (diff) | |
download | chromium_src-6e680cfca66d0461f2824ccb5128e4f9cbb20bb6.zip chromium_src-6e680cfca66d0461f2824ccb5128e4f9cbb20bb6.tar.gz chromium_src-6e680cfca66d0461f2824ccb5128e4f9cbb20bb6.tar.bz2 |
Rewrite base::JSONReader to be 35-40% faster, depending on the input string.
This change does the following:
* Parses the input string and generates the object representation in O(n) time.
* Optimizes string decoding by using StringPiece where possible, which also
introduces the JSON_DETACHABLE_CHILDREN parser option.
* Makes JSONReader a simpler interface by hiding the parser details in an
internal JSONParser class.
BUG=49212,111581,121469
TEST=Hopefully covered by all test suites. New tests added for edge cases.
Review URL: https://chromiumcodereview.appspot.com/10035042
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137430 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/test')
-rw-r--r-- | net/test/base_test_server.cc | 2 | ||||
-rw-r--r-- | net/test/spawner_communicator.cc | 4 |
2 files changed, 2 insertions, 4 deletions
diff --git a/net/test/base_test_server.cc b/net/test/base_test_server.cc index 533cb9d..07bef89 100644 --- a/net/test/base_test_server.cc +++ b/net/test/base_test_server.cc @@ -256,7 +256,7 @@ void BaseTestServer::SetResourcePath(const FilePath& document_root, bool BaseTestServer::ParseServerData(const std::string& server_data) { VLOG(1) << "Server data: " << server_data; base::JSONReader json_reader; - scoped_ptr<Value> value(json_reader.JsonToValue(server_data, true, false)); + scoped_ptr<Value> value(json_reader.ReadToValue(server_data)); if (!value.get() || !value->IsType(Value::TYPE_DICTIONARY)) { LOG(ERROR) << "Could not parse server data: " << json_reader.GetErrorMessage(); diff --git a/net/test/spawner_communicator.cc b/net/test/spawner_communicator.cc index 65b700a..308d080 100644 --- a/net/test/spawner_communicator.cc +++ b/net/test/spawner_communicator.cc @@ -321,9 +321,7 @@ bool SpawnerCommunicator::StartServer(const std::string& arguments, return false; // Check whether the data returned from spawner server is JSON-formatted. - base::JSONReader json_reader; - scoped_ptr<base::Value> value(json_reader.JsonToValue(server_return_data, - true, false)); + scoped_ptr<base::Value> value(base::JSONReader::Read(server_return_data)); if (!value.get() || !value->IsType(base::Value::TYPE_DICTIONARY)) { LOG(ERROR) << "Invalid server data: " << server_return_data.c_str(); return false; |