Skip to content

Commit 6975bb6

Browse files
committed
Do not recompute the diff type if possible
Computing the diff type is not expensive, but it's always a good thing to avoid unnecessary work.
1 parent 33194cd commit 6975bb6

2 files changed

Lines changed: 2 additions & 13 deletions

File tree

src/main/java/org/variantsync/diffdetective/diff/difftree/parse/MultiLineMacroParser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ ParseResult consume(
6464
if (beforeMLMacro != null) {
6565
return ParseResult.ERROR(MLMACRO_WITHIN_MLMACRO, "Found definition of multiline macro within multiline macro at line " + line + "!");
6666
}
67-
beforeMLMacro = new MultilineMacro(line, lineNo, beforeStack.peek(), afterStack.peek());
67+
beforeMLMacro = new MultilineMacro(line, diffType, lineNo, beforeStack.peek(), afterStack.peek());
6868
}
6969
if (!isRem) {
7070
if (afterMLMacro != null) {
7171
return ParseResult.ERROR(MLMACRO_WITHIN_MLMACRO, "Found definition of multiline macro within multiline macro at line " + line + "!");
7272
}
73-
afterMLMacro = new MultilineMacro(line, lineNo, beforeStack.peek(), afterStack.peek());
73+
afterMLMacro = new MultilineMacro(line, diffType, lineNo, beforeStack.peek(), afterStack.peek());
7474
}
7575
} else { // body
7676
// ... otherwise, it is a line within a body of a multiline macro. Thus append it.

src/main/java/org/variantsync/diffdetective/diff/difftree/parse/MultilineMacro.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,6 @@ public class MultilineMacro {
1616
DiffType diffType;
1717

1818
public MultilineMacro(
19-
final String header,
20-
final DiffLineNumber startLine,
21-
final DiffNode beforeParent,
22-
final DiffNode afterParent) {
23-
this(
24-
header, DiffType.ofDiffLine(header),
25-
startLine,
26-
beforeParent, afterParent);
27-
}
28-
29-
private MultilineMacro(
3019
final String line,
3120
final DiffType diffType,
3221
final DiffLineNumber startLine,

0 commit comments

Comments
 (0)