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

Unified Diff: sdk/lib/vmservice/vmservice.dart

Issue 2254543006: Reduce copying in sending service responses. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: dbc, sync Created 4 years, 4 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 | « runtime/vm/timeline.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/vmservice/vmservice.dart
diff --git a/sdk/lib/vmservice/vmservice.dart b/sdk/lib/vmservice/vmservice.dart
index 25ceb6a5a85290b9cafe5758fabe4b6dd9f23728..a56c2932d4e40df002f369d2ffabe7cb1f04517b 100644
--- a/sdk/lib/vmservice/vmservice.dart
+++ b/sdk/lib/vmservice/vmservice.dart
@@ -330,6 +330,15 @@ class VMService extends MessageRouter {
return encodeSuccess(message);
}
+ static responseAsJson(portResponse) {
+ if (portResponse is String) {
+ return JSON.decode(portResponse);
+ } else {
+ var cstring = portResponse[0];
+ return JSON.fuse(UTF8).decode(cstring);
+ }
+ }
+
// TODO(johnmccutchan): Turn this into a command line tool that uses the
// service library.
Future<String> _getCrashDump(Message message) async {
@@ -353,13 +362,13 @@ class VMService extends MessageRouter {
// Request VM.
var getVM = Uri.parse('getVM');
- var getVmResponse = JSON.decode(
+ var getVmResponse = responseAsJson(
await new Message.fromUri(client, getVM).sendToVM());
responses[getVM.toString()] = getVmResponse['result'];
// Request command line flags.
var getFlagList = Uri.parse('getFlagList');
- var getFlagListResponse = JSON.decode(
+ var getFlagListResponse = responseAsJson(
await new Message.fromUri(client, getFlagList).sendToVM());
responses[getFlagList.toString()] = getFlagListResponse['result'];
@@ -369,13 +378,13 @@ class VMService extends MessageRouter {
var message = new Message.forIsolate(client, request, isolate);
// Decode the JSON and and insert it into the map. The map key
// is the request Uri.
- var response = JSON.decode(await isolate.route(message));
+ var response = responseAsJson(await isolate.route(message));
responses[message.toUri().toString()] = response['result'];
}
// Dump the object id ring requests.
var message =
new Message.forIsolate(client, Uri.parse('_dumpIdZone'), isolate);
- var response = JSON.decode(await isolate.route(message));
+ var response = responseAsJson(await isolate.route(message));
// Insert getObject requests into responses map.
for (var object in response['result']['objects']) {
final requestUri =
« no previous file with comments | « runtime/vm/timeline.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698