remove redundant code

since `oldLinesCopy[0] === newLine` should always be classified as
`"same"` or `"old"` in the earlier block, the `else` statement (which
sets `isLineRemoval = true`)feels redundant and never actually executed.
This commit is contained in:
Keerthana Panyam 2025-03-18 15:35:51 -04:00
parent f6fa09bafd
commit 3ba54526fb

View file

@ -35,7 +35,6 @@ export async function* streamDiff(
let type: DiffLineType;
let isLineRemoval = false;
const isNewLine = matchIndex === -1;
if (isNewLine) {
@ -45,7 +44,6 @@ export async function* streamDiff(
for (let i = 0; i < matchIndex; i++) {
yield { type: "old", line: oldLinesCopy.shift()! };
}
type = isPerfectMatch ? "same" : "old";
}
@ -60,22 +58,13 @@ export async function* streamDiff(
case "old":
yield { type, line: oldLinesCopy.shift()! };
if (oldLinesCopy[0] !== newLine) {
yield { type: "new", line: newLine };
} else {
isLineRemoval = true;
}
yield { type: "new", line: newLine };
break;
default:
console.error(`Error streaming diff, unrecognized diff type: ${type}`);
}
if (!isLineRemoval) {
newLineResult = await newLines.next();
}
newLineResult = await newLines.next();
}
// Once at the edge, only one choice