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:
parent
f6fa09bafd
commit
3ba54526fb
1 changed files with 2 additions and 13 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue