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

Unified Diff: pkg/analysis_server/lib/src/services/generated/completion.dart

Issue 677303002: Remove unnecessary List creation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments Created 6 years, 2 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
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/ast.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/services/generated/completion.dart
diff --git a/pkg/analysis_server/lib/src/services/generated/completion.dart b/pkg/analysis_server/lib/src/services/generated/completion.dart
index bad6d0d57298b5ec0e22255646cb5e95d40a6cfb..d8550f0a0e706b0b5e4c8a21a635b5c855d857ec 100644
--- a/pkg/analysis_server/lib/src/services/generated/completion.dart
+++ b/pkg/analysis_server/lib/src/services/generated/completion.dart
@@ -818,16 +818,13 @@ class CompletionEngine {
bool _filterDisallows2(String name) => !_filter._match2(name);
List<Element> _findAllNotTypes(List<Element> elements) {
- elements = [];
- for (JavaIterator<Element> I = new JavaIterator(elements); I.hasNext;) {
- Element element = I.next();
+ return elements.where((Element element) {
ElementKind kind = element.kind;
- if (kind == ElementKind.FUNCTION || kind == ElementKind.TOP_LEVEL_VARIABLE || kind == ElementKind.GETTER || kind == ElementKind.SETTER) {
- continue;
- }
- I.remove();
- }
- return new List.from(elements);
+ return kind == ElementKind.FUNCTION
+ || kind == ElementKind.TOP_LEVEL_VARIABLE
+ || kind == ElementKind.GETTER
+ || kind == ElementKind.SETTER;
+ }).toList();
}
List<Element> _findAllPrefixes() {
@@ -841,16 +838,11 @@ class CompletionEngine {
}
List<Element> _findAllTypes2(List<Element> elements) {
- elements = [];
- for (JavaIterator<Element> I = new JavaIterator(elements); I.hasNext;) {
- Element element = I.next();
+ return elements.where((Element element) {
ElementKind kind = element.kind;
- if (kind == ElementKind.CLASS || kind == ElementKind.FUNCTION_TYPE_ALIAS) {
- continue;
- }
- I.remove();
- }
- return new List.from(elements);
+ return kind == ElementKind.CLASS
+ || kind == ElementKind.FUNCTION_TYPE_ALIAS;
+ }).toList();
}
List<Element> _findTopLevelElements(LibraryElement library, TopLevelNamesKind topKind) {
@@ -940,7 +932,7 @@ class CompletionEngine {
List<ImportElement> _importsWithName(SimpleIdentifier libName) {
String name = libName.name;
- List<ImportElement> imports = [];
+ List<ImportElement> imports = <ImportElement>[];
for (ImportElement imp in currentLibrary.imports) {
PrefixElement prefix = imp.prefix;
if (prefix != null) {
@@ -950,7 +942,7 @@ class CompletionEngine {
}
}
}
- return new List.from(imports);
+ return imports;
}
bool _isCompletingKeyword(Token keyword) {
@@ -1328,8 +1320,8 @@ class CompletionEngine {
types.add(param.type.toString());
}
}
- prop.setParameterNames(new List.from(params));
- prop.setParameterTypes(new List.from(types));
+ prop.setParameterNames(params);
+ prop.setParameterTypes(types);
prop.setParameterStyle(posCount, named, positional);
}
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/ast.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698