mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-28 17:41:54 +08:00
Perf: minor optimization reducing array allocation
This commit is contained in:
@@ -104,7 +104,7 @@ async function transform(parentSpan: Span, sourcePath: string, relativePath: str
|
|||||||
return parentSpan
|
return parentSpan
|
||||||
.traceChild(`transform ruleset: ${id}`)
|
.traceChild(`transform ruleset: ${id}`)
|
||||||
.traceAsyncFn(async (span) => {
|
.traceAsyncFn(async (span) => {
|
||||||
const type = relativePath.split(path.sep)[0];
|
const type = relativePath.slice(0, relativePath.indexOf(path.sep));
|
||||||
|
|
||||||
if (type !== 'ip' && type !== 'non_ip' && type !== 'domainset') {
|
if (type !== 'ip' && type !== 'non_ip' && type !== 'domainset') {
|
||||||
throw new TypeError(`Invalid type: ${type}`);
|
throw new TypeError(`Invalid type: ${type}`);
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ export class SurgeMitmSgmodule extends BaseWriteStrategy {
|
|||||||
urlRegex = urlRegex.slice(9);
|
urlRegex = urlRegex.slice(9);
|
||||||
}
|
}
|
||||||
|
|
||||||
const potentialHostname = urlRegex.split('/')[0]
|
const potentialHostname = urlRegex.slice(0, urlRegex.indexOf('/'))
|
||||||
// pre process regex
|
// pre process regex
|
||||||
.replaceAll(String.raw`\.`, '.')
|
.replaceAll(String.raw`\.`, '.')
|
||||||
.replaceAll('.+', '*')
|
.replaceAll('.+', '*')
|
||||||
|
|||||||
Reference in New Issue
Block a user