From b74ed9a36781de6a2347203513cc1645506a9eea Mon Sep 17 00:00:00 2001 From: SukkaW Date: Sat, 1 Feb 2025 23:56:14 +0800 Subject: [PATCH] Minor changes --- Build/lib/rules/base.ts | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/Build/lib/rules/base.ts b/Build/lib/rules/base.ts index 07e0b0fe..2ba1426a 100644 --- a/Build/lib/rules/base.ts +++ b/Build/lib/rules/base.ts @@ -514,14 +514,21 @@ export async function fileEqual(linesA: string[], source: AsyncIterable const lineA = linesA[index]; - if (lineA.length === 0 && lineB.length === 0) { - continue; - } - - // not both line are empty - if (lineA.length === 0 || lineB.length === 0) { + if (lineA.length === 0) { + if (lineB.length === 0) { + // both lines are empty, check next line + continue; + } + // lineA is empty but lineB is not return false; } + // now lineA can not be empty + if (lineB.length === 0) { + // lineB is empty but lineA is not + return false; + } + + // now both lines can not be empty const firstCharA = lineA.charCodeAt(0); const firstCharB = lineB.charCodeAt(0); @@ -530,16 +537,17 @@ export async function fileEqual(linesA: string[], source: AsyncIterable return false; } - if (firstCharA === 35 /* # */ && firstCharB === 35 /* # */) { + // now firstCharA is equal to firstCharB, we only need to check the first char + if (firstCharA === 35 /* # */) { continue; } // adguard conf - if (firstCharA === 33 /* ! */ && firstCharB === 33 /* ! */) { + if (firstCharA === 33 /* ! */) { continue; } if ( - firstCharA === 47 /* / */ && firstCharB === 47 /* / */ + firstCharA === 47 /* / */ && lineA[1] === '/' && lineB[1] === '/' && lineA[3] === '#' && lineB[3] === '#' ) {