gout

A static git page generator
git clone https://git.bracken.jp/gout.git
Log | Files | Refs | README | LICENSE

commit 97cfdef3c673313f4d9dc474e057687c87db97dd
parent 1921842b97fa1556ed595a55f861e65bfc2e8737
Author: Chris Bracken <chris@bracken.jp>
Date:   Fri,  6 Mar 2026 17:49:58 +0900

delta: eliminate redundant git_patch_get_hunk call in gitdelta_create

In gitdelta_create, we call git_patch_get_hunk to check for the hunk
before creating it, and if so, call githunk_create... where we do the
exact same check again and return NULL if we fail to get the hunk.
Instead we now just call githunk_create directly.

Diffstat:
Msrc/git/delta.c | 10+++-------
1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/src/git/delta.c b/src/git/delta.c @@ -140,13 +140,9 @@ GitDelta* gitdelta_create(git_patch* patch) { delta->hunks = ecalloc(hunk_count, sizeof(GitHunk*)); size_t hunks_out_count = 0; for (size_t i = 0; i < hunk_count; i++) { - const git_diff_hunk* hunk; - size_t line_count; - if (!git_patch_get_hunk(&hunk, &line_count, patch, i)) { - GitHunk* hunk = githunk_create(patch, i); - if (hunk) { - delta->hunks[hunks_out_count++] = hunk; - } + GitHunk* hunk = githunk_create(patch, i); + if (hunk) { + delta->hunks[hunks_out_count++] = hunk; } } delta->hunks_len = hunks_out_count;