Skip to content

Commit

Permalink
Update go.mod go version to 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
beevik committed Jun 2, 2024
1 parent 275fb76 commit c6c56d9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/beevik/prefixtree

go 1.18
go 1.21
24 changes: 3 additions & 21 deletions prefixtree.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ outerLoop:
if len(t.links) >= 20 {
ix := sort.Search(len(t.links),
func(i int) bool { return t.links[i].keyseg >= prefix })
start, stop = maxInt(0, ix-1), minInt(ix, stop)
start, stop = max(0, ix-1), min(ix, stop)

Check failure on line 158 in prefixtree.go

View workflow job for this annotation

GitHub Actions / build (1.18)

undefined: max

Check failure on line 158 in prefixtree.go

View workflow job for this annotation

GitHub Actions / build (1.18)

undefined: min
}

// Perform the check on all candidate links.
Expand Down Expand Up @@ -191,7 +191,7 @@ outerLoop:
// starting from the beginning of each string.
func matchingChars(s1, s2 string) int {
i := 0
for l := minInt(len(s1), len(s2)); i < l; i++ {
for l := min(len(s1), len(s2)); i < l; i++ {

Check failure on line 194 in prefixtree.go

View workflow job for this annotation

GitHub Actions / build (1.18)

undefined: min
if s1[i] != s2[i] {
break
}
Expand Down Expand Up @@ -258,7 +258,7 @@ outerLoop:
var splitLink *link
var splitIndex int
innerLoop:
for li, lm := maxInt(ix-1, 0), minInt(ix, len(t.links)-1); li <= lm; li++ {
for li, lm := max(ix-1, 0), min(ix, len(t.links)-1); li <= lm; li++ {

Check failure on line 261 in prefixtree.go

View workflow job for this annotation

GitHub Actions / build (1.18)

undefined: max

Check failure on line 261 in prefixtree.go

View workflow job for this annotation

GitHub Actions / build (1.18)

undefined: min
link := &t.links[li]
m := matchingChars(link.keyseg, k)
switch {
Expand Down Expand Up @@ -315,21 +315,3 @@ func (t *Tree) outputNode(level int) {
l.tree.outputNode(level + 1)
}
}

func minInt(a, b int) int {
switch {
case a < b:
return a
default:
return b
}
}

func maxInt(a, b int) int {
switch {
case a > b:
return a
default:
return b
}
}

0 comments on commit c6c56d9

Please sign in to comment.