CR feedback

This commit is contained in:
zhengbli 2015-10-15 13:53:37 -07:00
parent 3e37b3158b
commit ea9bf7313a
3 changed files with 3 additions and 8 deletions

View File

@ -360,7 +360,7 @@ namespace ts {
let newFileNames = ts.map(parsedCommandLine.fileNames, compilerHost.getCanonicalFileName);
let canonicalRootFileNames = ts.map(rootFileNames, compilerHost.getCanonicalFileName);
if (!arrayIsEqualTo(newFileNames, canonicalRootFileNames, /*comparer*/ undefined, /*sortBeforeComparison*/ true)) {
if (!arrayIsEqualTo(newFileNames.sort(), canonicalRootFileNames.sort())) {
setCachedProgram(undefined);
startTimerForRecompilation();
}

View File

@ -82,7 +82,7 @@ namespace ts {
return node.end - node.pos;
}
export function arrayIsEqualTo<T>(arr1: T[], arr2: T[], comparer?: (a: T, b: T) => boolean, sortBeforeComparison = false): boolean {
export function arrayIsEqualTo<T>(arr1: T[], arr2: T[], comparer?: (a: T, b: T) => boolean): boolean {
if (!arr1 || !arr2) {
return arr1 === arr2;
}
@ -91,11 +91,6 @@ namespace ts {
return false;
}
if (sortBeforeComparison) {
arr1.sort();
arr2.sort();
}
for (let i = 0; i < arr1.length; ++i) {
let equals = comparer ? comparer(arr1[i], arr2[i]) : arr1[i] === arr2[i];
if (!equals) {

View File

@ -576,7 +576,7 @@ namespace ts.server {
let newRootFiles = projectOptions.files.map((f => this.getCanonicalFileName(f)));
let currentRootFiles = project.getRootFiles().map((f => this.getCanonicalFileName(f)));
if (!arrayIsEqualTo(currentRootFiles, newRootFiles, /*comparer*/ undefined, /*sortBeforeComparison*/ true)) {
if (!arrayIsEqualTo(currentRootFiles.sort(), 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.