Reduce unnecessary arrow function allocations.

This commit is contained in:
Cyrus Najmabadi 2014-12-16 02:53:58 -08:00
parent c7bb0a5ae6
commit 592ad476a8
3 changed files with 7 additions and 7 deletions

View File

@ -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((<UnionType>type).types, t => getWidenedType(t)));
return getUnionType(map((<UnionType>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((<UnionType>type).types, t => isTupleLikeType(t)) : isTupleLikeType(type));
return !!(type.flags & TypeFlags.Union ? forEach((<UnionType>type).types, isTupleLikeType) : isTupleLikeType(type));
}
// Return true if the given contextual type provides an index signature of the given kind

View File

@ -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 => {

View File

@ -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());
}