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

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

Issue 677303002: Remove unnecessary List creation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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:
Download patch
Index: pkg/analyzer/lib/src/generated/resolver.dart
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index bcc7ad340a3d25aecdfa7561072d9543bbc1b82f..e41f345978827853952e48e01437615990263cc6 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -422,10 +422,10 @@ class AngularCompilationUnitBuilder {
* Parses [AngularPropertyElement]s from [annotation] and [classDeclaration].
*/
List<AngularPropertyElement> _parseComponentProperties() {
sra1 2014/10/26 06:31:39 It would be nice if this file was split into small
Brian Wilkerson 2014/10/26 15:15:46 Agreed. That's another task on my list, and anothe
- List<AngularPropertyElement> properties = [];
+ List<AngularPropertyElement> properties = <AngularPropertyElement>[];
_parseComponentProperties_fromMap(properties);
_parseComponentProperties_fromFields(properties);
- return new List.from(properties);
+ return properties;
}
/**
@@ -611,9 +611,9 @@ class AngularCompilationUnitBuilder {
}
List<AngularScopePropertyElement> _parseScopeProperties() {
- List<AngularScopePropertyElement> properties = [];
+ List<AngularScopePropertyElement> properties = <AngularScopePropertyElement>[];
_classDeclaration.accept(new RecursiveAstVisitor_AngularCompilationUnitBuilder_parseScopeProperties(properties));
- return new List.from(properties);
+ return properties;
}
/**
@@ -621,10 +621,10 @@ class AngularCompilationUnitBuilder {
* where <code>view</code> is <code>ViewFactory</code>.
*/
void _parseViews() {
- List<AngularViewElement> views = [];
+ List<AngularViewElement> views = <AngularViewElement>[];
_unit.accept(new RecursiveAstVisitor_AngularCompilationUnitBuilder_parseViews(views));
if (!views.isEmpty) {
- List<AngularViewElement> viewArray = new List.from(views);
+ List<AngularViewElement> viewArray = views;
(_unit.element as CompilationUnitElementImpl).angularViews = viewArray;
}
}
@@ -4298,7 +4298,7 @@ class ElementHolder {
List<LabelElement> _labels;
- List<VariableElement> _localVariables;
+ List<LocalVariableElement> _localVariables;
List<MethodElement> _methods;
@@ -4356,7 +4356,7 @@ class ElementHolder {
void addLocalVariable(LocalVariableElement element) {
if (_localVariables == null) {
- _localVariables = new List<VariableElement>();
+ _localVariables = new List<LocalVariableElement>();
}
_localVariables.add(element);
}
@@ -4407,7 +4407,7 @@ class ElementHolder {
if (_accessors == null) {
return PropertyAccessorElementImpl.EMPTY_ARRAY;
}
- List<PropertyAccessorElement> result = new List.from(_accessors);
+ List<PropertyAccessorElement> result = _accessors;
_accessors = null;
return result;
}
@@ -4416,7 +4416,7 @@ class ElementHolder {
if (_constructors == null) {
return ConstructorElementImpl.EMPTY_ARRAY;
}
- List<ConstructorElement> result = new List.from(_constructors);
+ List<ConstructorElement> result = _constructors;
_constructors = null;
return result;
}
@@ -4425,7 +4425,7 @@ class ElementHolder {
if (_enums == null) {
return ClassElementImpl.EMPTY_ARRAY;
}
- List<ClassElement> result = new List.from(_enums);
+ List<ClassElement> result = _enums;
_enums = null;
return result;
}
@@ -4446,7 +4446,7 @@ class ElementHolder {
if (_fields == null) {
return FieldElementImpl.EMPTY_ARRAY;
}
- List<FieldElement> result = new List.from(_fields);
+ List<FieldElement> result = _fields;
_fields = null;
return result;
}
@@ -4455,7 +4455,7 @@ class ElementHolder {
if (_fields == null) {
return FieldElementImpl.EMPTY_ARRAY;
}
- List<FieldElement> result = new List.from(_fields);
+ List<FieldElement> result = _fields;
return result;
}
@@ -4463,7 +4463,7 @@ class ElementHolder {
if (_functions == null) {
return FunctionElementImpl.EMPTY_ARRAY;
}
- List<FunctionElement> result = new List.from(_functions);
+ List<FunctionElement> result = _functions;
_functions = null;
return result;
}
@@ -4472,7 +4472,7 @@ class ElementHolder {
if (_labels == null) {
return LabelElementImpl.EMPTY_ARRAY;
}
- List<LabelElement> result = new List.from(_labels);
+ List<LabelElement> result = _labels;
_labels = null;
return result;
}
@@ -4481,7 +4481,7 @@ class ElementHolder {
if (_localVariables == null) {
return LocalVariableElementImpl.EMPTY_ARRAY;
}
- List<LocalVariableElement> result = new List.from(_localVariables);
+ List<LocalVariableElement> result = _localVariables;
_localVariables = null;
return result;
}
@@ -4490,7 +4490,7 @@ class ElementHolder {
if (_methods == null) {
return MethodElementImpl.EMPTY_ARRAY;
}
- List<MethodElement> result = new List.from(_methods);
+ List<MethodElement> result = _methods;
_methods = null;
return result;
}
@@ -4499,7 +4499,7 @@ class ElementHolder {
if (_parameters == null) {
return ParameterElementImpl.EMPTY_ARRAY;
}
- List<ParameterElement> result = new List.from(_parameters);
+ List<ParameterElement> result = _parameters;
_parameters = null;
return result;
}
@@ -4520,7 +4520,7 @@ class ElementHolder {
if (_topLevelVariables == null) {
return TopLevelVariableElementImpl.EMPTY_ARRAY;
}
- List<TopLevelVariableElement> result = new List.from(_topLevelVariables);
+ List<TopLevelVariableElement> result = _topLevelVariables;
_topLevelVariables = null;
return result;
}
@@ -4529,7 +4529,7 @@ class ElementHolder {
if (_typeAliases == null) {
return FunctionTypeAliasElementImpl.EMPTY_ARRAY;
}
- List<FunctionTypeAliasElement> result = new List.from(_typeAliases);
+ List<FunctionTypeAliasElement> result = _typeAliases;
_typeAliases = null;
return result;
}
@@ -4538,7 +4538,7 @@ class ElementHolder {
if (_typeParameters == null) {
return TypeParameterElementImpl.EMPTY_ARRAY;
}
- List<TypeParameterElement> result = new List.from(_typeParameters);
+ List<TypeParameterElement> result = _typeParameters;
_typeParameters = null;
return result;
}
@@ -4547,7 +4547,7 @@ class ElementHolder {
if (_types == null) {
return ClassElementImpl.EMPTY_ARRAY;
}
- List<ClassElement> result = new List.from(_types);
+ List<ClassElement> result = _types;
_types = null;
return result;
}
@@ -7178,7 +7178,7 @@ class ElementResolver extends SimpleAstVisitor<Object> {
}
}
if (!annotationList.isEmpty) {
- (element as ElementImpl).metadata = new List.from(annotationList);
+ (element as ElementImpl).metadata = annotationList;
}
}
@@ -7197,7 +7197,7 @@ class ElementResolver extends SimpleAstVisitor<Object> {
List<ElementAnnotationImpl> annotationList = new List<ElementAnnotationImpl>();
_addAnnotations(annotationList, node.metadata);
if (!annotationList.isEmpty) {
- (element as ElementImpl).metadata = new List.from(annotationList);
+ (element as ElementImpl).metadata = annotationList;
}
}
@@ -7401,8 +7401,8 @@ class EnumMemberBuilder extends RecursiveAstVisitor<Object> {
//
// Finish building the enum.
//
- enumElement.fields = new List.from(fields);
- enumElement.accessors = new List.from(getters);
+ enumElement.fields = fields;
+ enumElement.accessors = getters;
// Client code isn't allowed to invoke the constructor, so we do not model it.
return super.visitEnumDeclaration(node);
}
@@ -13035,8 +13035,7 @@ class ExitDetector extends GeneralizingAstVisitor<bool> {
_enclosingBlockContainsBreak = false;
try {
bool hasDefault = false;
- NodeList<SwitchMember> memberList = node.members;
- List<SwitchMember> members = new List.from(memberList);
+ List<SwitchMember> members = node.members;
for (int i = 0; i < members.length; i++) {
SwitchMember switchMember = members[i];
if (switchMember is SwitchDefault) {
@@ -13765,7 +13764,7 @@ class ImplicitConstructorBuilder extends ScopedVisitor {
implicitConstructors.add(_createImplicitContructor(classType, explicitConstructor, parameterTypes, argumentTypes));
}
}
- classElement.constructors = new List.from(implicitConstructors);
+ classElement.constructors = implicitConstructors;
}
}
}
@@ -15465,7 +15464,7 @@ class Library {
unitArrayList.add(getAST(source));
}
}
- return new List.from(unitArrayList);
+ return unitArrayList;
}
/**
@@ -15740,7 +15739,7 @@ class LibraryElementBuilder {
libraryElement.entryPoint = entryPoint;
}
int sourcedUnitCount = sourcedCompilationUnits.length;
- libraryElement.parts = new List.from(sourcedCompilationUnits);
+ libraryElement.parts = sourcedCompilationUnits;
for (Directive directive in directivesToResolve) {
directive.element = libraryElement;
}
@@ -15828,7 +15827,7 @@ class LibraryElementBuilder {
libraryElement.entryPoint = entryPoint;
}
int sourcedUnitCount = sourcedCompilationUnits.length;
- libraryElement.parts = new List.from(sourcedCompilationUnits);
+ libraryElement.parts = sourcedCompilationUnits;
for (Directive directive in directivesToResolve) {
directive.element = libraryElement;
}
@@ -16059,9 +16058,8 @@ class LibraryImportScope extends Scope {
if (indirectCount > 0) {
builder.append(" (via ");
if (indirectCount > 1) {
- List<String> indirectNames = new List.from(indirectSources);
- indirectNames.sort();
- builder.append(StringUtilities.printListOfQuotedNames(indirectNames));
+ indirectSources.sort();
+ builder.append(StringUtilities.printListOfQuotedNames(indirectSources));
} else {
builder.append(indirectSources[0]);
}
@@ -16449,7 +16447,7 @@ class LibraryResolver {
combinators.add(show);
}
}
- return new List.from(combinators);
+ return combinators;
}
/**
@@ -16541,8 +16539,8 @@ class LibraryResolver {
imports.add(importElement);
}
LibraryElementImpl libraryElement = library.libraryElement;
- libraryElement.imports = new List.from(imports);
- libraryElement.exports = new List.from(exports);
+ libraryElement.imports = imports;
+ libraryElement.exports = exports;
if (libraryElement.entryPoint == null) {
Namespace namespace = new NamespaceBuilder().createExportNamespaceForLibrary(libraryElement);
Element element = namespace.get(LibraryElementBuilder.ENTRY_POINT_NAME);
@@ -16756,7 +16754,7 @@ class LibraryResolver {
importedLibraries.add(importedLibrary);
}
}
- library.importedLibraries = new List.from(importedLibraries);
+ library.importedLibraries = importedLibraries;
List<Library> exportedLibraries = new List<Library>();
for (Source exportedSource in exportedSources) {
Library exportedLibrary = _libraryMap[exportedSource];
@@ -16770,7 +16768,7 @@ class LibraryResolver {
exportedLibraries.add(exportedLibrary);
}
}
- library.exportedLibraries = new List.from(exportedLibraries);
+ library.exportedLibraries = exportedLibraries;
library.explicitlyImportsCore = explicitlyImportsCore;
if (!explicitlyImportsCore && _coreLibrarySource != library.librarySource) {
Library importedLibrary = _libraryMap[_coreLibrarySource];
@@ -17111,7 +17109,7 @@ class LibraryResolver2 {
combinators.add(show);
}
}
- return new List.from(combinators);
+ return combinators;
}
/**
@@ -17207,8 +17205,8 @@ class LibraryResolver2 {
imports.add(importElement);
}
LibraryElementImpl libraryElement = library.libraryElement;
- libraryElement.imports = new List.from(imports);
- libraryElement.exports = new List.from(exports);
+ libraryElement.imports = imports;
+ libraryElement.exports = exports;
if (libraryElement.entryPoint == null) {
Namespace namespace = new NamespaceBuilder().createExportNamespaceForLibrary(libraryElement);
Element element = namespace.get(LibraryElementBuilder.ENTRY_POINT_NAME);
@@ -24478,7 +24476,7 @@ class TypeResolverVisitor extends ScopedVisitor {
elements.add(element);
}
}
- return new List.from(elements);
+ return elements;
}
/**
@@ -24700,17 +24698,17 @@ class TypeResolverVisitor extends ScopedVisitor {
classElement.interfaces = interfaceTypes;
}
// TODO(brianwilkerson) Move the following checks to ErrorVerifier.
- List<TypeName> typeNames = new List.from(interfaces);
- List<bool> detectedRepeatOnIndex = new List<bool>.filled(typeNames.length, false);
+ int count = interfaces.length;
+ List<bool> detectedRepeatOnIndex = new List<bool>.filled(count, false);
for (int i = 0; i < detectedRepeatOnIndex.length; i++) {
detectedRepeatOnIndex[i] = false;
}
- for (int i = 0; i < typeNames.length; i++) {
- TypeName typeName = typeNames[i];
+ for (int i = 0; i < count; i++) {
+ TypeName typeName = interfaces[i];
if (!detectedRepeatOnIndex[i]) {
Element element = typeName.name.staticElement;
- for (int j = i + 1; j < typeNames.length; j++) {
- TypeName typeName2 = typeNames[j];
+ for (int j = i + 1; j < count; j++) {
+ TypeName typeName2 = interfaces[j];
Identifier identifier2 = typeName2.name;
String name2 = identifier2.name;
Element element2 = identifier2.staticElement;
@@ -24772,7 +24770,7 @@ class TypeResolverVisitor extends ScopedVisitor {
types.add(type);
}
}
- return new List.from(types);
+ return types;
}
void _setElement(Identifier typeName, Element element) {

Powered by Google App Engine
This is Rietveld 408576698