Skip to content

Commit b30dab8

Browse files
committed
apply: refactor to use a switch statement
1 parent 001d76e commit b30dab8

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/apply.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -206,16 +206,20 @@ static int apply_hunk(
206206
goto done;
207207
}
208208

209-
if (line->origin == GIT_DIFF_LINE_CONTEXT ||
210-
line->origin == GIT_DIFF_LINE_DELETION) {
211-
if ((error = git_vector_insert(&preimage.lines, line)) < 0)
212-
goto done;
213-
}
214-
215-
if (line->origin == GIT_DIFF_LINE_CONTEXT ||
216-
line->origin == GIT_DIFF_LINE_ADDITION) {
217-
if ((error = git_vector_insert(&postimage.lines, line)) < 0)
218-
goto done;
209+
switch (line->origin) {
210+
case GIT_DIFF_LINE_CONTEXT:
211+
if ((error = git_vector_insert(&preimage.lines, line)) < 0 ||
212+
(error = git_vector_insert(&postimage.lines, line)) < 0)
213+
goto done;
214+
break;
215+
case GIT_DIFF_LINE_DELETION:
216+
if ((error = git_vector_insert(&preimage.lines, line)) < 0)
217+
goto done;
218+
break;
219+
case GIT_DIFF_LINE_ADDITION:
220+
if ((error = git_vector_insert(&postimage.lines, line)) < 0)
221+
goto done;
222+
break;
219223
}
220224
}
221225

0 commit comments

Comments
 (0)