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

Unified Diff: runtime/vm/object.cc

Issue 1653183002: getObject now supports specifying offset,count for strings. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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/json_test.cc ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index df6fde0d7ba841ad7fb6223f3caf2ec26c7bb876..d587b54731cf1f001948a105396fadb27da96213 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -20207,15 +20207,27 @@ void String::PrintJSONImpl(JSONStream* stream, bool ref) const {
PrintSharedInstanceJSON(&jsobj, ref);
jsobj.AddProperty("kind", "String");
jsobj.AddServiceId(*this);
+ jsobj.AddProperty("length", Length());
if (ref) {
- bool did_truncate = jsobj.AddPropertyStr("valueAsString", *this, 128);
- if (did_truncate) {
- jsobj.AddProperty("valueAsStringIsTruncated", did_truncate);
+ // String refs always truncate to a fixed count;
+ const intptr_t kFixedCount = 128;
+ if (jsobj.AddPropertyStr("valueAsString", *this, 0, kFixedCount)) {
+ jsobj.AddProperty("count", kFixedCount);
+ jsobj.AddProperty("valueAsStringIsTruncated", true);
}
- } else {
- bool did_truncate = jsobj.AddPropertyStr("valueAsString", *this);
- ASSERT(!did_truncate);
+ return;
+ }
+
+ intptr_t offset;
+ intptr_t count;
+ stream->ComputeOffsetAndCount(Length(), &offset, &count);
+ if (offset > 0) {
+ jsobj.AddProperty("offset", offset);
+ }
+ if (count < Length()) {
+ jsobj.AddProperty("count", count);
}
+ jsobj.AddPropertyStr("valueAsString", *this, offset, count);
}
« no previous file with comments | « runtime/vm/json_test.cc ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698