Skip to content

Commit

Permalink
Use Go's 1.21 clear function to clear pixels with 0
Browse files Browse the repository at this point in the history
  • Loading branch information
elgopher committed Jul 30, 2023
1 parent 01fd62d commit 8e6a697
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
1 change: 0 additions & 1 deletion internal/bench/screen_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ func runBenchmarks(b *testing.B, callback func(res Resolution)) {
var resolutions = [...]Resolution{
{W: 128, H: 128},
{W: 256, H: 256},
{W: 512, H: 512},
}

for _, resolution := range resolutions {
Expand Down
5 changes: 1 addition & 4 deletions pixmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ type PixMap struct {
height int
clip Region

zeroPix []byte
wholeLinePix []byte
}

Expand All @@ -38,7 +37,6 @@ func NewPixMap(width, height int) PixMap {
width: width,
height: height,
clip: Region{W: width, H: height},
zeroPix: make([]byte, len(pixels)),
wholeLinePix: make([]byte, width),
}
}
Expand Down Expand Up @@ -78,7 +76,6 @@ func NewPixMapWithPixels(pixels []byte, lineWidth int) PixMap {
width: lineWidth,
height: height,
clip: Region{W: lineWidth, H: height},
zeroPix: make([]byte, len(pixels)),
wholeLinePix: make([]byte, lineWidth),
}
}
Expand Down Expand Up @@ -141,7 +138,7 @@ func (p PixMap) WithClip(x, y, w, h int) PixMap {

// Clear clears the entire PixMap with color 0. It does not take into account the clipping region.
func (p PixMap) Clear() {
copy(p.pix, p.zeroPix)
clear(p.pix)
}

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

0 comments on commit 8e6a697

Please sign in to comment.