mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2026-12-02 04:39:46 -06:00
Quick tweaks
This commit is contained in:
@@ -44,3 +44,14 @@ export function remove<U, V extends U>(arr: U[], v: V) {
|
||||
return arr.filter(item => item !== v) as Exclude<U, V extends null | undefined ? V : never>[];
|
||||
}
|
||||
// https://www.typescriptlang.org/play?#code/KYDwDg9gTgLgBAMwK4DsDGMCWEVysAWwgDdgAeAVQBo4A1OUGYFAEwGc4KA+ACgEMoUAFycA2gF0axEbQCUcAN4AoOKrzAYSKLgFQAdAkwAbJlB6YmBOAF4ucC4TgBCa9bjF5fDgFEQaI0gs5NR0DCBMrBwoSEZGcAA+cKhBhijALHAA-KEiaaRQXBIA3EoAvkpKQf4CwHBoOGzwuiI8jVCYKADmCXDRsbLFFfUojXAgNupEpPyCNH1GsiUA9EtqcAB6mUMN8ACeE-hTwDNQNABECBAQZ4tKK2ubFUA
|
||||
|
||||
// For Array.prototype.sort
|
||||
export function basic_comparator<T>(a: T, b: T) {
|
||||
if (a < b) {
|
||||
return -1;
|
||||
} else if (a > b) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-10
@@ -41,7 +41,7 @@ import {logger} from './logger';
|
||||
import {ClientOptionsHandler, OptionHandlerArguments} from './options-handler';
|
||||
import {CompilerProps} from './properties';
|
||||
import {PropertyGetter} from './properties.interfaces';
|
||||
import {remove} from './common-utils';
|
||||
import {basic_comparator, remove} from './common-utils';
|
||||
|
||||
const sleep = promisify(setTimeout);
|
||||
|
||||
@@ -456,15 +456,7 @@ export class CompilerFinder {
|
||||
const result = this.ensureDistinct(compilers);
|
||||
return {
|
||||
foundClash: result.foundClash,
|
||||
compilers: result.compilers.sort((a, b) => {
|
||||
if (a.name < b.name) {
|
||||
return -1;
|
||||
} else if (a.name > b.name) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}),
|
||||
compilers: result.compilers.sort((a, b) => basic_comparator(a.name, b.name)),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user