Performance improvement for FindReposLastestCommitStatuses
If `commitstatus_service.FindReposLastestCommitStatuses` receives no repos in its params, short-circuit, and return early, without performing any potentially expensive work. Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu> (cherry picked from commit 33cd8446d3675796939c7204e31814c0c0bbcbab)
This commit is contained in:
parent
dd8d3f5ebe
commit
275f5326a1
1 changed files with 3 additions and 0 deletions
|
@ -120,6 +120,9 @@ func CreateCommitStatus(ctx context.Context, repo *repo_model.Repository, creato
|
||||||
|
|
||||||
// FindReposLastestCommitStatuses loading repository default branch latest combinded commit status with cache
|
// FindReposLastestCommitStatuses loading repository default branch latest combinded commit status with cache
|
||||||
func FindReposLastestCommitStatuses(ctx context.Context, repos []*repo_model.Repository) ([]*git_model.CommitStatus, error) {
|
func FindReposLastestCommitStatuses(ctx context.Context, repos []*repo_model.Repository) ([]*git_model.CommitStatus, error) {
|
||||||
|
if len(repos) == 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
results := make([]*git_model.CommitStatus, len(repos))
|
results := make([]*git_model.CommitStatus, len(repos))
|
||||||
for i, repo := range repos {
|
for i, repo := range repos {
|
||||||
if cv := getCommitStatusCache(repo.ID, repo.DefaultBranch); cv != nil {
|
if cv := getCommitStatusCache(repo.ID, repo.DefaultBranch); cv != nil {
|
||||||
|
|
Loading…
Reference in a new issue