Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Unified Diff: chrome/test/base/ui_test_utils.cc

Issue 10035042: Rewrite base::JSONReader to be 35-40% faster, depending on the input string. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Really fix Windows, address comments Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/installer/util/master_preferences_unittest.cc ('k') | net/test/base_test_server.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/base/ui_test_utils.cc
diff --git a/chrome/test/base/ui_test_utils.cc b/chrome/test/base/ui_test_utils.cc
index b4548bf166608e4c3c67e03313c7f01a9744cede..4cab58a6e26a91772e49c054435b3f33fb74bbbc 100644
--- a/chrome/test/base/ui_test_utils.cc
+++ b/chrome/test/base/ui_test_utils.cc
@@ -249,28 +249,13 @@ bool ExecuteJavaScriptHelper(RenderViewHost* render_view_host,
if (!result)
return true;
- // Wrap |json| in an array before deserializing because valid JSON has an
- // array or an object as the root.
- json.insert(0, "[");
- json.append("]");
-
- scoped_ptr<Value> root_val(
- base::JSONReader::Read(json, base::JSON_ALLOW_TRAILING_COMMAS));
- if (!root_val->IsType(Value::TYPE_LIST)) {
- DLOG(ERROR) << "JSON result is not a list.";
+ base::JSONReader reader(base::JSON_ALLOW_TRAILING_COMMAS);
+ result->reset(reader.ReadToValue(json));
+ if (!result->get()) {
+ DLOG(ERROR) << reader.GetErrorMessage();
return false;
}
- ListValue* list = static_cast<ListValue*>(root_val.get());
- Value* result_val;
- if (!list || !list->GetSize() ||
- // Remove gives us ownership of the value.
- !list->Remove(0, &result_val)) {
- DLOG(ERROR) << "JSON result list is empty.";
- return false;
- }
-
- result->reset(result_val);
return true;
}
« no previous file with comments | « chrome/installer/util/master_preferences_unittest.cc ('k') | net/test/base_test_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698