Chromium Code Reviews| 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; |