mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-28 17:41:54 +08:00
Use foxts more
This commit is contained in:
@@ -7,7 +7,8 @@ import { treeDir, TreeFileType } from './lib/tree-dir';
|
|||||||
import type { TreeType, TreeTypeArray } from './lib/tree-dir';
|
import type { TreeType, TreeTypeArray } from './lib/tree-dir';
|
||||||
|
|
||||||
import { OUTPUT_MOCK_DIR, OUTPUT_MODULES_RULES_DIR, PUBLIC_DIR, ROOT_DIR } from './constants/dir';
|
import { OUTPUT_MOCK_DIR, OUTPUT_MODULES_RULES_DIR, PUBLIC_DIR, ROOT_DIR } from './constants/dir';
|
||||||
import { fastStringCompare, writeFile } from './lib/misc';
|
import { writeFile } from './lib/misc';
|
||||||
|
import { fastStringCompare } from 'foxts/fast-string-compare';
|
||||||
import type { VoidOrVoidArray } from './lib/misc';
|
import type { VoidOrVoidArray } from './lib/misc';
|
||||||
import picocolors from 'picocolors';
|
import picocolors from 'picocolors';
|
||||||
import { tagged as html } from 'foxts/tagged';
|
import { tagged as html } from 'foxts/tagged';
|
||||||
|
|||||||
@@ -6,26 +6,6 @@ import { appendArrayInPlace } from 'foxts/append-array-in-place';
|
|||||||
|
|
||||||
export type MaybePromise<T> = T | Promise<T>;
|
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 {
|
interface Write {
|
||||||
(
|
(
|
||||||
destination: string,
|
destination: string,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* Hostbane-Optimized Trie based on Mnemonist Trie
|
* Hostbane-Optimized Trie based on Mnemonist Trie
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { fastStringCompare } from './misc';
|
import { fastStringCompare } from 'foxts/fast-string-compare';
|
||||||
import util from 'node:util';
|
import util from 'node:util';
|
||||||
import { noop } from 'foxts/noop';
|
import { noop } from 'foxts/noop';
|
||||||
import { fastStringArrayJoin } from 'foxts/fast-string-array-join';
|
import { fastStringArrayJoin } from 'foxts/fast-string-array-join';
|
||||||
|
|||||||
Reference in New Issue
Block a user