Use a simpler implementation of Diagnosticable.toString when running in profile/release mode (#28661)

Diagnosticable.toString may be called in performance sensitive contexts
(for example, creating debug labels for Tickers)
This commit is contained in:
Jason Simmons
2019-03-04 11:05:20 -08:00
committed by GitHub
parent c3527389b6
commit a1aea2e442

View File

@@ -2127,7 +2127,12 @@ abstract class Diagnosticable {
@override
String toString({ DiagnosticLevel minLevel = DiagnosticLevel.debug }) {
return toDiagnosticsNode(style: DiagnosticsTreeStyle.singleLine).toString(minLevel: minLevel);
String fullString;
assert(() {
fullString = toDiagnosticsNode(style: DiagnosticsTreeStyle.singleLine).toString(minLevel: minLevel);
return true;
}());
return fullString ?? toStringShort();
}
/// Returns a debug representation of the object that is used by debugging