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

Unified Diff: pkg/analyzer/lib/src/generated/utilities_general.dart

Issue 954013002: Replace try/finally with PerformanceTag.makeCurrentWhile(). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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
Index: pkg/analyzer/lib/src/generated/utilities_general.dart
diff --git a/pkg/analyzer/lib/src/generated/utilities_general.dart b/pkg/analyzer/lib/src/generated/utilities_general.dart
index 1ae55e6a1d3abb57865e79f728e6c8197c895f29..e62a7815e633926fe40fca86a920a24f3b26ce59 100644
--- a/pkg/analyzer/lib/src/generated/utilities_general.dart
+++ b/pkg/analyzer/lib/src/generated/utilities_general.dart
@@ -80,6 +80,12 @@ abstract class PerformanceTag {
PerformanceTag makeCurrent();
/**
+ * Make this the current tag for the isolate, run [f], and restore the
+ * previous tag. Returns the result of invoking [f].
+ */
+ makeCurrentWhile(f());
+
+ /**
* Reset the total time tracked by all [PerformanceTag]s to zero.
*/
static void reset() {
@@ -114,7 +120,8 @@ class _PerformanceTagImpl implements PerformanceTag {
final Stopwatch stopwatch;
_PerformanceTagImpl(String label)
- : userTag = new UserTag(label), stopwatch = new Stopwatch() {
+ : userTag = new UserTag(label),
+ stopwatch = new Stopwatch() {
all.add(this);
}
@@ -136,4 +143,13 @@ class _PerformanceTagImpl implements PerformanceTag {
userTag.makeCurrent();
return previous;
}
+
+ makeCurrentWhile(f()) {
+ PerformanceTag prevTag = makeCurrent();
+ try {
+ return f();
+ } finally {
+ prevTag.makeCurrent();
+ }
+ }
}

Powered by Google App Engine
This is Rietveld 408576698