mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-31 11:52:10 +00:00
chore: remove usages of sort.Sort
(#6689)
improve language stats rounding: - Add tests (I had to omit some edge cases as the current method is non-determistic in some cases, due to random order of map access). - Document the algorithm used. - Lower the amount of calculations that need to be done. - Because of the aforementioned non-determistic don't use stable sort and instead regular sort. better sorting for `RepositoryList`: - Add testing - Use `slices.Sortfunc` instead of `sort.Sort`. - Remove the methods needed for `sort.Sort`. better git tag sorter: - Use `slices.SortFunc` instead of `sort.Sort`. - Remove `tagSorter` and its related methods. - Added testing. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6689 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: Gusted <postmaster@gusted.xyz> Co-committed-by: Gusted <postmaster@gusted.xyz>
This commit is contained in:
parent
048af05db9
commit
270a2c7fa3
8 changed files with 97 additions and 51 deletions
|
@ -36,18 +36,6 @@ const RepositoryListDefaultPageSize = 64
|
|||
// RepositoryList contains a list of repositories
|
||||
type RepositoryList []*Repository
|
||||
|
||||
func (repos RepositoryList) Len() int {
|
||||
return len(repos)
|
||||
}
|
||||
|
||||
func (repos RepositoryList) Less(i, j int) bool {
|
||||
return repos[i].FullName() < repos[j].FullName()
|
||||
}
|
||||
|
||||
func (repos RepositoryList) Swap(i, j int) {
|
||||
repos[i], repos[j] = repos[j], repos[i]
|
||||
}
|
||||
|
||||
// ValuesRepository converts a repository map to a list
|
||||
// FIXME: Remove in favor of maps.values when MIN_GO_VERSION >= 1.18
|
||||
func ValuesRepository(m map[int64]*Repository) []*Repository {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue