Skip to content

Commit

Permalink
Short-circuit comparisons that have already failed
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewbranch committed Dec 13, 2022
1 parent 54d350f commit 4257fe4
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/compiler/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -978,10 +978,10 @@ export function detectSortCaseSensitivity<T>(array: readonly T[], useEslintOrder
for (let i = 1, len = array.length; i < len; i++) {
const prevElement = array[i - 1];
const element = array[i];
if (caseSensitiveComparer(prevElement, element) === Comparison.GreaterThan) {
if (kind & SortKind.CaseSensitive && caseSensitiveComparer(prevElement, element) === Comparison.GreaterThan) {
kind &= ~SortKind.CaseSensitive;
}
if (caseInsensitiveComparer(prevElement, element) === Comparison.GreaterThan) {
if (kind & SortKind.CaseInsensitive && caseInsensitiveComparer(prevElement, element) === Comparison.GreaterThan) {
kind &= ~SortKind.CaseInsensitive;
}
if (kind === SortKind.None) {
Expand All @@ -991,7 +991,6 @@ export function detectSortCaseSensitivity<T>(array: readonly T[], useEslintOrder
return kind;
}


/** @internal */
export function arrayIsEqualTo<T>(array1: readonly T[] | undefined, array2: readonly T[] | undefined, equalityComparer: (a: T, b: T, index: number) => boolean = equateValues): boolean {
if (!array1 || !array2) {
Expand Down

0 comments on commit 4257fe4

Please sign in to comment.