Skip to content

Commit

Permalink
Use a simpler implementation of Diagnosticable.toString when running …
Browse files Browse the repository at this point in the history
…in profile/release mode (flutter#28661)

Diagnosticable.toString may be called in performance sensitive contexts
(for example, creating debug labels for Tickers)
  • Loading branch information
jason-simmons authored Mar 4, 2019
1 parent c352738 commit a1aea2e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/flutter/lib/src/foundation/diagnostics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a1aea2e

Please sign in to comment.