CR feedback

This commit is contained in:
zhengbli
2015-10-19 21:48:40 -07:00
parent e7e1fa72ec
commit 39254b54ae
3 changed files with 4 additions and 8 deletions

View File

@@ -361,7 +361,7 @@ namespace ts {
let canonicalRootFileNames = ts.map(rootFileNames, compilerHost.getCanonicalFileName);
// We check if the project file list has changed. If so, we just throw away the old program and start fresh.
if (!arrayIsEqualTo(newFileNames, canonicalRootFileNames, /*equaler*/ undefined, /*sortBeforeComparison*/ true)) {
if (!arrayIsEqualTo(newFileNames && newFileNames.sort(), canonicalRootFileNames && canonicalRootFileNames.sort())) {
setCachedProgram(undefined);
startTimerForRecompilation();
}

View File

@@ -82,8 +82,7 @@ namespace ts {
return node.end - node.pos;
}
export function arrayIsEqualTo<T>(array1: T[], array2: T[], equaler?: (a: T, b: T) => boolean,
sortBeforeComparison?: boolean, comparer?: (a: T, b: T) => number): boolean {
export function arrayIsEqualTo<T>(array1: T[], array2: T[], equaler?: (a: T, b: T) => boolean): boolean {
if (!array1 || !array2) {
return array1 === array2;
}
@@ -92,11 +91,8 @@ namespace ts {
return false;
}
let newArray1 = sortBeforeComparison ? array1.slice().sort(comparer) : array1;
let newArray2 = sortBeforeComparison ? array2.slice().sort(comparer) : array2;
for (let i = 0; i < array1.length; ++i) {
let equals = equaler ? equaler(newArray1[i], newArray2[i]) : newArray1[i] === newArray2[i];
let equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i];
if (!equals) {
return false;
}

View File

@@ -577,7 +577,7 @@ namespace ts.server {
let currentRootFiles = project.getRootFiles().map((f => this.getCanonicalFileName(f)));
// We check if the project file list has changed. If so, we update the project.
if (!arrayIsEqualTo(currentRootFiles, newRootFiles, /*equaler*/ undefined, /*sortBeforeComparison*/ true)) {
if (!arrayIsEqualTo(currentRootFiles && currentRootFiles.sort(), newRootFiles && newRootFiles.sort())) {
// For configured projects, the change is made outside the tsconfig file, and
// it is not likely to affect the project for other files opened by the client. We can
// just update the current project.