aboutsummaryrefslogtreecommitdiff
path: root/internal/postgres
diff options
context:
space:
mode:
authorHana Kim <hyangah@gmail.com>2026-03-05 22:45:44 -0500
committerHyang-Ah Hana Kim <hyangah@gmail.com>2026-03-17 15:34:02 -0700
commit1b7f032dee11d6534119541bc3e03f0fcbcc4995 (patch)
tree06e281dc35f162a95a51e077c78666dfef3d6541 /internal/postgres
parent084157e2536c982e9dc669e8f289ec26dcc27891 (diff)
downloadgo-x-pkgsite-1b7f032dee11d6534119541bc3e03f0fcbcc4995.tar.xz
all: fix minmax
Change-Id: I1eacfe303e724fc4dfe371b10a3762627162285d Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/753425 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> kokoro-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Ethan Lee <ethanalee@google.com>
Diffstat (limited to 'internal/postgres')
-rw-r--r--internal/postgres/path_test.go5
-rw-r--r--internal/postgres/searchdoc.go5
2 files changed, 2 insertions, 8 deletions
diff --git a/internal/postgres/path_test.go b/internal/postgres/path_test.go
index 1b06d90b..e2b04d22 100644
--- a/internal/postgres/path_test.go
+++ b/internal/postgres/path_test.go
@@ -168,10 +168,7 @@ func TestUpsertPathsConcurrently(t *testing.T) {
i := i
go func() {
start := (10 * i) % len(paths)
- end := start + 50
- if end > len(paths) {
- end = len(paths)
- }
+ end := min(start+50, len(paths))
sub := paths[start:end]
got, err := upsertPathsInTx(ctx, testDB.db, sub)
if err == nil {
diff --git a/internal/postgres/searchdoc.go b/internal/postgres/searchdoc.go
index b78fffa0..60830e3f 100644
--- a/internal/postgres/searchdoc.go
+++ b/internal/postgres/searchdoc.go
@@ -53,10 +53,7 @@ func searchDocumentSections(synopsis, readmeFilename, readme string, maxSecWords
rwd := append(rwfd, rwr...)
// Keep maxSecWords of section D, but not more than maxReadmeFrac.
f := int(maxReadmeFrac * float64(len(rwd)))
- nkeep := maxSecWords
- if nkeep > f {
- nkeep = f
- }
+ nkeep := min(maxSecWords, f)
sectionD, _ := split(rwd, nkeep)
// If there is no synopsis, use first sentence of the README.