Skip to content

Commit b1592d6

Browse files
committed
Use Go's 1.21 clear function to clear pixels with 0
1 parent 66f8aa7 commit b1592d6

File tree

2 files changed

+1
-5
lines changed

2 files changed

+1
-5
lines changed

internal/bench/screen_bench_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ func runBenchmarks(b *testing.B, callback func(res Resolution)) {
132132
var resolutions = [...]Resolution{
133133
{W: 128, H: 128},
134134
{W: 256, H: 256},
135-
{W: 512, H: 512},
136135
}
137136

138137
for _, resolution := range resolutions {

pixmap.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ type PixMap struct {
2323
height int
2424
clip Region
2525

26-
zeroPix []byte
2726
wholeLinePix []byte
2827
}
2928

@@ -44,7 +43,6 @@ func NewPixMap(width, height int) PixMap {
4443
width: width,
4544
height: height,
4645
clip: Region{W: width, H: height},
47-
zeroPix: make([]byte, len(pixels)),
4846
wholeLinePix: make([]byte, width),
4947
}
5048
}
@@ -84,7 +82,6 @@ func NewPixMapWithPixels(pixels []byte, lineWidth int) PixMap {
8482
width: lineWidth,
8583
height: height,
8684
clip: Region{W: lineWidth, H: height},
87-
zeroPix: make([]byte, len(pixels)),
8885
wholeLinePix: make([]byte, lineWidth),
8986
}
9087
}
@@ -147,7 +144,7 @@ func (p PixMap) WithClip(x, y, w, h int) PixMap {
147144

148145
// Clear clears the entire PixMap with color 0. It does not take into account the clipping region.
149146
func (p PixMap) Clear() {
150-
copy(p.pix, p.zeroPix)
147+
clear(p.pix)
151148
}
152149

153150
// ClearCol clears the entire PixMap with specified color. It does not take into account the clipping region.

0 commit comments

Comments
 (0)