Skip to content

Commit a1aea2e

Browse files
Use a simpler implementation of Diagnosticable.toString when running in profile/release mode (flutter#28661)
Diagnosticable.toString may be called in performance sensitive contexts (for example, creating debug labels for Tickers)
1 parent c352738 commit a1aea2e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/flutter/lib/src/foundation/diagnostics.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2127,7 +2127,12 @@ abstract class Diagnosticable {
21272127

21282128
@override
21292129
String toString({ DiagnosticLevel minLevel = DiagnosticLevel.debug }) {
2130-
return toDiagnosticsNode(style: DiagnosticsTreeStyle.singleLine).toString(minLevel: minLevel);
2130+
String fullString;
2131+
assert(() {
2132+
fullString = toDiagnosticsNode(style: DiagnosticsTreeStyle.singleLine).toString(minLevel: minLevel);
2133+
return true;
2134+
}());
2135+
return fullString ?? toStringShort();
21312136
}
21322137

21332138
/// Returns a debug representation of the object that is used by debugging

0 commit comments

Comments
 (0)