From 592ad476a82f1db516705b6aea96e29c4fe5539b Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 16 Dec 2014 02:53:58 -0800 Subject: [PATCH] Reduce unnecessary arrow function allocations. --- src/compiler/checker.ts | 10 +++++----- src/harness/harness.ts | 2 +- src/services/services.ts | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6f39161d161..b04ac3f321c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -763,7 +763,7 @@ module ts { // if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table) // and if symbolfrom symbolTable or alias resolution matches the symbol, // check the symbol can be qualified, it is only then this symbol is accessible - return !forEach(symbolFromSymbolTable.declarations, declaration => hasExternalModuleSymbol(declaration)) && + return !forEach(symbolFromSymbolTable.declarations, hasExternalModuleSymbol) && canQualifySymbol(symbolFromSymbolTable, meaning); } } @@ -867,7 +867,7 @@ module ts { // This could be a symbol that is not exported in the external module // or it could be a symbol from different external module that is not aliased and hence cannot be named - var symbolExternalModule = forEach(initialSymbol.declarations, declaration => getExternalModuleContainer(declaration)); + var symbolExternalModule = forEach(initialSymbol.declarations, getExternalModuleContainer); if (symbolExternalModule) { var enclosingExternalModule = getExternalModuleContainer(enclosingDeclaration); if (symbolExternalModule !== enclosingExternalModule) { @@ -1087,7 +1087,7 @@ module ts { } else { // If we didn't find accessible symbol chain for this symbol, break if this is external module - if (!parentSymbol && ts.forEach(symbol.declarations, declaration => hasExternalModuleSymbol(declaration))) { + if (!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) { return; } @@ -4101,7 +4101,7 @@ module ts { return anyType; } if (type.flags & TypeFlags.Union) { - return getUnionType(map((type).types, t => getWidenedType(t))); + return getUnionType(map((type).types, getWidenedType)); } if (isTypeOfObjectLiteral(type)) { return getWidenedTypeOfObjectLiteral(type); @@ -5072,7 +5072,7 @@ module ts { // Return true if the given contextual type is a tuple-like type function contextualTypeIsTupleLikeType(type: Type): boolean { - return !!(type.flags & TypeFlags.Union ? forEach((type).types, t => isTupleLikeType(t)) : isTupleLikeType(type)); + return !!(type.flags & TypeFlags.Union ? forEach((type).types, isTupleLikeType) : isTupleLikeType(type)); } // Return true if the given contextual type provides an index signature of the given kind diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 311e2db93ee..d0276e8b0ce 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1187,7 +1187,7 @@ module Harness { // Report global errors var globalErrors = diagnostics.filter(err => !err.filename); - globalErrors.forEach(err => outputErrorText(err)); + globalErrors.forEach(outputErrorText); // 'merge' the lines of each input file with any errors associated with it inputFiles.filter(f => f.content !== undefined).forEach(inputFile => { diff --git a/src/services/services.ts b/src/services/services.ts index 25e7548a0d6..bf1952c952e 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -3172,7 +3172,7 @@ module ts { } if (symbolFlags & SymbolFlags.Enum) { addNewLineIfDisplayPartsExist(); - if (forEach(symbol.declarations, declaration => isConstEnumDeclaration(declaration))) { + if (forEach(symbol.declarations, isConstEnumDeclaration)) { displayParts.push(keywordPart(SyntaxKind.ConstKeyword)); displayParts.push(spacePart()); }