@@ -702,7 +702,7 @@ namespace ts {
702702 function deduplicateRelational < T > ( array : ReadonlyArray < T > , equalityComparer : EqualityComparer < T > , comparer : Comparer < T > ) {
703703 // Perform a stable sort of the array. This ensures the first entry in a list of
704704 // duplicates remains the first entry in the result.
705- const indices = sequence ( 0 , array . length ) ;
705+ const indices = array . map ( ( _ , i ) => i ) ;
706706 stableSortIndices ( array , indices , comparer ) ;
707707
708708 let last = array [ indices [ 0 ] ] ;
@@ -895,17 +895,6 @@ namespace ts {
895895 }
896896 }
897897
898- /**
899- * Creates an array of integers starting at `from` (inclusive) and ending at `to` (exclusive).
900- */
901- function sequence ( from : number , to : number ) {
902- const numbers : number [ ] = [ ] ;
903- for ( let i = from ; i < to ; i ++ ) {
904- numbers . push ( i ) ;
905- }
906- return numbers ;
907- }
908-
909898 function stableSortIndices < T > ( array : ReadonlyArray < T > , indices : number [ ] , comparer : Comparer < T > ) {
910899 // sort indices by value then position
911900 indices . sort ( ( x , y ) => comparer ( array [ x ] , array [ y ] ) || compareValues ( x , y ) ) ;
@@ -922,7 +911,7 @@ namespace ts {
922911 * Stable sort of an array. Elements equal to each other maintain their relative position in the array.
923912 */
924913 export function stableSort < T > ( array : ReadonlyArray < T > , comparer : Comparer < T > ) {
925- const indices = sequence ( 0 , array . length ) ;
914+ const indices = array . map ( ( _ , i ) => i ) ;
926915 stableSortIndices ( array , indices , comparer ) ;
927916 return indices . map ( i => array [ i ] ) as ReadonlyArray < T > as SortedReadonlyArray < T > ;
928917 }
@@ -1009,7 +998,7 @@ namespace ts {
1009998 * @param array A sorted array whose first element must be no larger than number
1010999 * @param number The value to be searched for in the array.
10111000 */
1012- export function binarySearch < T , U > ( array : ReadonlyArray < T > , value : T , keySelector : Selector < T , U > , keyComparer : Comparer < U > , offset ?: number ) : number {
1001+ export function binarySearch < T , U > ( array : ReadonlyArray < T > , value : T , keySelector : ( v : T ) => U , keyComparer : Comparer < U > , offset ?: number ) : number {
10131002 if ( ! array || array . length === 0 ) {
10141003 return - 1 ;
10151004 }
@@ -1764,8 +1753,8 @@ namespace ts {
17641753 }
17651754 } ) ( ) ;
17661755
1767- let uiCS : Comparer < string > | undefined ;
1768- let uiCI : Comparer < string > | undefined ;
1756+ let uiComparerCaseSensitive : Comparer < string > | undefined ;
1757+ let uiComparerCaseInsensitive : Comparer < string > | undefined ;
17691758 let uiLocale : string | undefined ;
17701759
17711760 export function getUILocale ( ) {
@@ -1775,8 +1764,8 @@ namespace ts {
17751764 export function setUILocale ( value : string ) {
17761765 if ( uiLocale !== value ) {
17771766 uiLocale = value ;
1778- uiCS = undefined ;
1779- uiCI = undefined ;
1767+ uiComparerCaseSensitive = undefined ;
1768+ uiComparerCaseInsensitive = undefined ;
17801769 }
17811770 }
17821771
@@ -1791,7 +1780,7 @@ namespace ts {
17911780 * accents/diacritic marks as unequal.
17921781 */
17931782 export function compareStringsCaseInsensitiveUI ( a : string , b : string ) {
1794- const comparer = uiCI || ( uiCI = createStringComparer ( uiLocale , /*caseInsensitive*/ true ) ) ;
1783+ const comparer = uiComparerCaseInsensitive || ( uiComparerCaseInsensitive = createStringComparer ( uiLocale , /*caseInsensitive*/ true ) ) ;
17951784 return comparer ( a , b ) ;
17961785 }
17971786
@@ -1806,7 +1795,7 @@ namespace ts {
18061795 * accents/diacritic marks, or case as unequal.
18071796 */
18081797 export function compareStringsCaseSensitiveUI ( a : string , b : string ) {
1809- const comparer = uiCS || ( uiCS = createStringComparer ( uiLocale , /*caseInsensitive*/ false ) ) ;
1798+ const comparer = uiComparerCaseSensitive || ( uiComparerCaseSensitive = createStringComparer ( uiLocale , /*caseInsensitive*/ false ) ) ;
18101799 return comparer ( a , b ) ;
18111800 }
18121801
0 commit comments