diff options
author | oliverpool <3864879+oliverpool@users.noreply.github.com> | 2024-04-09 14:27:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-09 20:27:30 +0800 |
commit | d547b53cca8a9a7ac96449910bae5d811728c251 (patch) | |
tree | 2d356c8a7e06855b16ecc289ba9dce92ceeb5f77 /web_src/svg/gitea-maven.svg | |
parent | 8d14266269f1b4fd5e13d701830919c1a1613444 (diff) | |
download | gitea-d547b53cca8a9a7ac96449910bae5d811728c251.tar.gz gitea-d547b53cca8a9a7ac96449910bae5d811728c251.zip |
Add container.FilterSlice function (#30339)
Many places have the following logic:
```go
func (jobs ActionJobList) GetRunIDs() []int64 {
ids := make(container.Set[int64], len(jobs))
for _, j := range jobs {
if j.RunID == 0 {
continue
}
ids.Add(j.RunID)
}
return ids.Values()
}
```
this introduces a `container.FilterMapUnique` function, which reduces
the code above to:
```go
func (jobs ActionJobList) GetRunIDs() []int64 {
return container.FilterMapUnique(jobs, func(j *ActionRunJob) (int64, bool) {
return j.RunID, j.RunID != 0
})
}
```
Diffstat (limited to 'web_src/svg/gitea-maven.svg')
0 files changed, 0 insertions, 0 deletions