0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-12-15 23:54:02 +01:00
gitea/modules/container
oliverpool d547b53cca
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
	})
}
```
2024-04-09 20:27:30 +08:00
..
filter.go Add container.FilterSlice function (#30339) 2024-04-09 20:27:30 +08:00
filter_test.go Add container.FilterSlice function (#30339) 2024-04-09 20:27:30 +08:00
set.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
set_test.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00