Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions canvas.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bufio"
"bytes"
"io"
"slices"
"sort"
)

Expand Down Expand Up @@ -31,12 +32,7 @@ var reservedRunes = map[rune]bool{
}

func contains(in []rune, r rune) bool {
for _, v := range in {
if r == v {
return true
}
}
return false
return slices.Contains(in, r)
}

func isJoint(r rune) bool {
Expand Down
2 changes: 1 addition & 1 deletion examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestExamplesStableOutput(t *testing.T) {
c := qt.New(t)

var previous string
for i := 0; i < 3; i++ {
for i := range 3 {
in, err := os.Open(filepath.Join(basePath, "circuits.txt"))
if err != nil {
t.Fatal(err)
Expand Down
12 changes: 6 additions & 6 deletions iter.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ func upDown(width int, height int) chan Index {
c := make(chan Index, width*height)

go func() {
for w := 0; w < width; w++ {
for h := 0; h < height; h++ {
for w := range width {
for h := range height {
c <- Index{w, h}
}
}
Expand Down Expand Up @@ -40,8 +40,8 @@ func diagDown(width int, height int) chan Index {
maxSum := width

for sum := minSum; sum <= maxSum; sum++ {
for w := 0; w < width; w++ {
for h := 0; h < height; h++ {
for w := range width {
for h := range height {
if w-h == sum {
c <- Index{w, h}
}
Expand All @@ -61,8 +61,8 @@ func diagUp(width int, height int) chan Index {
maxSum := width + height - 2

for sum := 0; sum <= maxSum; sum++ {
for w := 0; w < width; w++ {
for h := 0; h < height; h++ {
for w := range width {
for h := range height {
if h+w == sum {
c <- Index{w, h}
}
Expand Down
2 changes: 1 addition & 1 deletion svg.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func BuildAndWriteSVG(src io.Reader, dst io.Writer) {
writeBytes(dst, "</svg>\n")
}

func writeBytes(out io.Writer, format string, args ...interface{}) {
func writeBytes(out io.Writer, format string, args ...any) {
bytesOut := fmt.Sprintf(format, args...)

_, err := out.Write([]byte(bytesOut))
Expand Down