Skip to content

Commit c25571e

Browse files
committed
Only parse the code type when needed
The code type is not needed in all code paths. It needs some time, which is not negligible (regular expression match), to parse the code type, so it should not be parsed in all code paths. Consequently, the variable can be declared in a smaller scope to make that fact obvious to the reader (and a bit more to the compiler).
1 parent a4c5b69 commit c25571e

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ ParseResult consume(
5151
final Stack<DiffNode> afterStack,
5252
final List<DiffNode> nodes
5353
) throws IllFormedAnnotationException {
54-
final CodeType codeType = CodeType.ofDiffLine(line);
5554
final DiffType diffType = DiffType.ofDiffLine(line);
5655
final boolean isAdd = diffType == DiffType.ADD;
5756
final boolean isRem = diffType == DiffType.REM;
5857

5958
if (continuesMultilineDefinition(line)) {
6059
// If this multiline macro line is a header...
60+
final CodeType codeType = CodeType.ofDiffLine(line);
6161
if (codeType.isConditionalMacro()) {
6262
// ... create a new multi line macro to complete.
6363
if (!isAdd) {

0 commit comments

Comments
 (0)