apply: refactor to use a switch statement
diff --git a/src/apply.c b/src/apply.c
index f876e43..291d63b 100644
--- a/src/apply.c
+++ b/src/apply.c
@@ -206,16 +206,20 @@ static int apply_hunk(
goto done;
}
- if (line->origin == GIT_DIFF_LINE_CONTEXT ||
- line->origin == GIT_DIFF_LINE_DELETION) {
- if ((error = git_vector_insert(&preimage.lines, line)) < 0)
- goto done;
- }
-
- if (line->origin == GIT_DIFF_LINE_CONTEXT ||
- line->origin == GIT_DIFF_LINE_ADDITION) {
- if ((error = git_vector_insert(&postimage.lines, line)) < 0)
- goto done;
+ switch (line->origin) {
+ case GIT_DIFF_LINE_CONTEXT:
+ if ((error = git_vector_insert(&preimage.lines, line)) < 0 ||
+ (error = git_vector_insert(&postimage.lines, line)) < 0)
+ goto done;
+ break;
+ case GIT_DIFF_LINE_DELETION:
+ if ((error = git_vector_insert(&preimage.lines, line)) < 0)
+ goto done;
+ break;
+ case GIT_DIFF_LINE_ADDITION:
+ if ((error = git_vector_insert(&postimage.lines, line)) < 0)
+ goto done;
+ break;
}
}