Skip to content

Commit 982c944

Browse files
committed
Use Go's 1.21 clear function to clear pixels with 0
1 parent f8ea5c1 commit 982c944

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

@@ -49,7 +48,6 @@ func NewPixMap(width, height int) PixMap {
4948
width: width,
5049
height: height,
5150
clip: Region{W: width, H: height},
52-
zeroPix: make([]byte, len(pixels)),
5351
wholeLinePix: make([]byte, width),
5452
}
5553
}
@@ -89,7 +87,6 @@ func NewPixMapWithPixels(pixels []byte, lineWidth int) PixMap {
8987
width: lineWidth,
9088
height: height,
9189
clip: Region{W: lineWidth, H: height},
92-
zeroPix: make([]byte, len(pixels)),
9390
wholeLinePix: make([]byte, lineWidth),
9491
}
9592
}
@@ -152,7 +149,7 @@ func (p PixMap) WithClip(x, y, w, h int) PixMap {
152149

153150
// Clear clears the entire PixMap with color 0. It does not take into account the clipping region.
154151
func (p PixMap) Clear() {
155-
copy(p.pix, p.zeroPix)
152+
clear(p.pix)
156153
}
157154

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

0 commit comments

Comments
 (0)