mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-29 01:51:52 +08:00
Use foxts more
This commit is contained in:
@@ -6,26 +6,6 @@ import { appendArrayInPlace } from 'foxts/append-array-in-place';
|
||||
|
||||
export type MaybePromise<T> = T | Promise<T>;
|
||||
|
||||
export function fastStringCompare(a: string, b: string) {
|
||||
const lenA = a.length;
|
||||
const lenB = b.length;
|
||||
const minLen = lenA < lenB ? lenA : lenB;
|
||||
|
||||
for (let i = 0; i < minLen; ++i) {
|
||||
const ca = a.charCodeAt(i);
|
||||
const cb = b.charCodeAt(i);
|
||||
|
||||
if (ca > cb) return 1;
|
||||
if (ca < cb) return -1;
|
||||
}
|
||||
|
||||
if (lenA === lenB) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return lenA > lenB ? 1 : -1;
|
||||
};
|
||||
|
||||
interface Write {
|
||||
(
|
||||
destination: string,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Hostbane-Optimized Trie based on Mnemonist Trie
|
||||
*/
|
||||
|
||||
import { fastStringCompare } from './misc';
|
||||
import { fastStringCompare } from 'foxts/fast-string-compare';
|
||||
import util from 'node:util';
|
||||
import { noop } from 'foxts/noop';
|
||||
import { fastStringArrayJoin } from 'foxts/fast-string-array-join';
|
||||
|
||||
Reference in New Issue
Block a user