Skip to content

Commit 39254b5

Browse files
committed
CR feedback
1 parent e7e1fa7 commit 39254b5

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

src/compiler/tsc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ namespace ts {
361361
let canonicalRootFileNames = ts.map(rootFileNames, compilerHost.getCanonicalFileName);
362362

363363
// We check if the project file list has changed. If so, we just throw away the old program and start fresh.
364-
if (!arrayIsEqualTo(newFileNames, canonicalRootFileNames, /*equaler*/ undefined, /*sortBeforeComparison*/ true)) {
364+
if (!arrayIsEqualTo(newFileNames && newFileNames.sort(), canonicalRootFileNames && canonicalRootFileNames.sort())) {
365365
setCachedProgram(undefined);
366366
startTimerForRecompilation();
367367
}

src/compiler/utilities.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ namespace ts {
8282
return node.end - node.pos;
8383
}
8484

85-
export function arrayIsEqualTo<T>(array1: T[], array2: T[], equaler?: (a: T, b: T) => boolean,
86-
sortBeforeComparison?: boolean, comparer?: (a: T, b: T) => number): boolean {
85+
export function arrayIsEqualTo<T>(array1: T[], array2: T[], equaler?: (a: T, b: T) => boolean): boolean {
8786
if (!array1 || !array2) {
8887
return array1 === array2;
8988
}
@@ -92,11 +91,8 @@ namespace ts {
9291
return false;
9392
}
9493

95-
let newArray1 = sortBeforeComparison ? array1.slice().sort(comparer) : array1;
96-
let newArray2 = sortBeforeComparison ? array2.slice().sort(comparer) : array2;
97-
9894
for (let i = 0; i < array1.length; ++i) {
99-
let equals = equaler ? equaler(newArray1[i], newArray2[i]) : newArray1[i] === newArray2[i];
95+
let equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i];
10096
if (!equals) {
10197
return false;
10298
}

src/server/editorServices.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ namespace ts.server {
577577
let currentRootFiles = project.getRootFiles().map((f => this.getCanonicalFileName(f)));
578578

579579
// We check if the project file list has changed. If so, we update the project.
580-
if (!arrayIsEqualTo(currentRootFiles, newRootFiles, /*equaler*/ undefined, /*sortBeforeComparison*/ true)) {
580+
if (!arrayIsEqualTo(currentRootFiles && currentRootFiles.sort(), newRootFiles && newRootFiles.sort())) {
581581
// For configured projects, the change is made outside the tsconfig file, and
582582
// it is not likely to affect the project for other files opened by the client. We can
583583
// just update the current project.

0 commit comments

Comments
 (0)