mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-05 11:37:46 +00:00
machine/nrf: do not compare slices against nil
Comparing slices against nil currently causes the slice to escape, due to a limitation in LLVM 8. This leads to lots of unnecessary heap allocations. With LLVM 9 and some modifications to TinyGo, this should be fixed. However, this commit is an easy win right now. Returning an error when both slices are nil is not necessary, when the check is left out it should just do nothing. For updating an SPI screen using the st7735 driver, this results in a ~7% performance win.
This commit is contained in:
committed by
Ron Evans
parent
832f301a74
commit
4164c39a4a
@@ -9,7 +9,6 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
ErrTxSlicesRequired = errors.New("SPI Tx requires a write or read slice, or both")
|
||||
ErrTxInvalidSliceSize = errors.New("SPI write and read slices must be same size")
|
||||
)
|
||||
|
||||
@@ -348,10 +347,6 @@ func (spi SPI) Transfer(w byte) (byte, error) {
|
||||
// spi.Tx(nil, rx)
|
||||
//
|
||||
func (spi SPI) Tx(w, r []byte) error {
|
||||
if w == nil && r == nil {
|
||||
return ErrTxSlicesRequired
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
switch {
|
||||
|
||||
Reference in New Issue
Block a user