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

Unified Diff: pkg/analyzer/lib/src/dart/analysis/driver.dart

Issue 2535053002: Time box _FilesReferencingNameTask. (Closed)
Patch Set: Remove debug output. Created 4 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/analysis/driver.dart
diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart
index 329f385c52d47eafcf9642f393b06da55b547552..c72732ac2bccb3a0c8fb24fa871d5414aafdb6d3 100644
--- a/pkg/analyzer/lib/src/dart/analysis/driver.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart
@@ -1256,30 +1256,33 @@ class _FilesReferencingNameTask {
_FilesReferencingNameTask(this.driver, this.name);
/**
- * Perform a single chunk of work, and either complete the [completer] and
+ * Perform work for `10 ms`, and either complete the [completer] and
Paul Berry 2016/11/28 20:17:40 This says "10 ms" but the code below seems to allo
scheglov 2016/11/28 20:20:17 Ah, good idea. Done.
* return `true` to indicate that the task is done, return `false` to
* indicate that the task should continue to be run.
*/
Future<bool> perform() async {
- // Prepare files to check.
- if (filesToCheck.isEmpty) {
- Set<String> newFiles = driver.addedFiles.difference(checkedFiles);
- filesToCheck.addAll(newFiles);
- }
+ Stopwatch timer = new Stopwatch()..start();
+ while (timer.elapsedMilliseconds < 5) {
Brian Wilkerson 2016/11/28 20:45:04 Please add a comment describing the tradeoffs you
scheglov 2016/11/28 21:19:27 Done.
+ // Prepare files to check.
+ if (filesToCheck.isEmpty) {
+ Set<String> newFiles = driver.addedFiles.difference(checkedFiles);
+ filesToCheck.addAll(newFiles);
+ }
- // If no more files to check, complete and done.
- if (filesToCheck.isEmpty) {
- completer.complete(referencingFiles);
- return true;
- }
+ // If no more files to check, complete and done.
+ if (filesToCheck.isEmpty) {
Brian Wilkerson 2016/11/28 20:45:04 Do we need to perform these two checks on every it
scheglov 2016/11/28 21:19:27 These checks are cheap.
+ completer.complete(referencingFiles);
+ return true;
+ }
- // Check the next file.
- String path = filesToCheck.removeLast();
- FileState file = driver._fsState.getFileForPath(path);
- if (file.referencedNames.contains(name)) {
- referencingFiles.add(path);
+ // Check the next file.
+ String path = filesToCheck.removeLast();
+ FileState file = driver._fsState.getFileForPath(path);
+ if (file.referencedNames.contains(name)) {
+ referencingFiles.add(path);
+ }
+ checkedFiles.add(path);
}
- checkedFiles.add(path);
// We're not done yet.
return false;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698