diff options
| author | saturneric <[email protected]> | 2025-11-07 21:45:02 +0000 |
|---|---|---|
| committer | saturneric <[email protected]> | 2025-11-07 21:45:02 +0000 |
| commit | eda7af97852dce34f952550c64091a8f14505bcf (patch) | |
| tree | af70c267c7bcc79e1dbd166fdb913e70055daf49 /ui-repolist.c | |
| parent | feat(repolist): improve repo activity time detection (diff) | |
| download | cgit-eda7af97852dce34f952550c64091a8f14505bcf.tar.gz cgit-eda7af97852dce34f952550c64091a8f14505bcf.zip | |
refactor(repolist): simplify repository initialization logic
* Remove redundant allocation and clearing of repository object
* Use shared `the_repository` for initialization and commit time retrieval
* Improve code clarity and reduce memory management overhead
Diffstat (limited to 'ui-repolist.c')
| -rw-r--r-- | ui-repolist.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/ui-repolist.c b/ui-repolist.c index 9aae04f..7af01bd 100644 --- a/ui-repolist.c +++ b/ui-repolist.c @@ -98,20 +98,16 @@ static int repo_last_activity_time(const struct cgit_repo *repo, int include_tags, time_t *out) { - repo_clear(the_repository); - - struct repository *r = xcalloc(1, sizeof(*r)); - if (repo_init(r, repo->path, NULL)) { + if (repo_init(the_repository, repo->path, NULL)) { error("failed to init repository at %s", repo->path); - free(r); return 0; } - repo_set_hash_algo(the_repository, hash_algo_by_ptr(r->hash_algo)); - - timestamp_t t1 = repo_latest_commit_ctime(r, include_tags); + timestamp_t t1 = repo_latest_commit_ctime(the_repository, include_tags); timestamp_t best = t1; + repo_clear(the_repository); + if (best <= 0) { *out = 0; return 0; } *out = (time_t)best; return 1; |
