loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request 'Replace IfZero with cmp.Or' (#2854) from snematoda/revert-ifzero into forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2854
Reviewed-by: oliverpool <oliverpool@noreply.codeberg.org>

Gusted c2e7f1a0 42b97fd8

+3 -13
+3 -4
modules/git/grep.go
··· 6 6 import ( 7 7 "bufio" 8 8 "bytes" 9 + "cmp" 9 10 "context" 10 11 "errors" 11 12 "fmt" 12 13 "os" 13 14 "strconv" 14 15 "strings" 15 - 16 - "code.gitea.io/gitea/modules/util" 17 16 ) 18 17 19 18 type GrepResult struct { ··· 59 58 } else { 60 59 cmd.AddOptionValues("-e", strings.TrimLeft(search, "-")) 61 60 } 62 - cmd.AddDynamicArguments(util.IfZero(opts.RefName, "HEAD")) 63 - opts.MaxResultLimit = util.IfZero(opts.MaxResultLimit, 50) 61 + cmd.AddDynamicArguments(cmp.Or(opts.RefName, "HEAD")) 62 + opts.MaxResultLimit = cmp.Or(opts.MaxResultLimit, 50) 64 63 stderr := bytes.Buffer{} 65 64 err = cmd.Run(&RunOpts{ 66 65 Dir: repo.Path,
-9
modules/util/util.go
··· 212 212 func ToPointer[T any](val T) *T { 213 213 return &val 214 214 } 215 - 216 - // IfZero returns "def" if "v" is a zero value, otherwise "v" 217 - func IfZero[T comparable](v, def T) T { 218 - var zero T 219 - if v == zero { 220 - return def 221 - } 222 - return v 223 - }