Limit summary string lengths to 200 characters.
Strings longer than 200 characters are now truncated and are shown
with a trailing "..." instead of an end quote. The number 200 was
chosen arbitrarily.
Bug: 23223379
Change-Id: I96d7c9d563026233ff5f4962245b4c276d776a58
diff --git a/tools/ahat/src/Value.java b/tools/ahat/src/Value.java
index 9b483fa..4eb27b1 100644
--- a/tools/ahat/src/Value.java
+++ b/tools/ahat/src/Value.java
@@ -25,6 +25,10 @@
*/
class Value {
+ // For string literals, we limit the number of characters we show to
+ // kMaxChars in case the string is really long.
+ private static int kMaxChars = 200;
+
/**
* Create a DocString representing a summary of the given instance.
*/
@@ -43,15 +47,19 @@
link.append(inst.toString());
// Annotate Strings with their values.
- String stringValue = InstanceUtils.asString(inst);
+ String stringValue = InstanceUtils.asString(inst, kMaxChars);
if (stringValue != null) {
- link.appendFormat("\"%s\"", stringValue);
+ link.appendFormat("\"%s", stringValue);
+ link.append(kMaxChars == stringValue.length() ? "..." : "\"");
}
// Annotate DexCache with its location.
- String dexCacheLocation = InstanceUtils.getDexCacheLocation(inst);
+ String dexCacheLocation = InstanceUtils.getDexCacheLocation(inst, kMaxChars);
if (dexCacheLocation != null) {
- link.append(" for " + dexCacheLocation);
+ link.appendFormat(" for %s", dexCacheLocation);
+ if (kMaxChars == dexCacheLocation.length()) {
+ link.append("...");
+ }
}
URI objTarget = DocString.formattedUri("object?id=%d", inst.getId());