atsame5x: reduce heap allocation

This commit is contained in:
sago35
2022-11-25 20:16:45 +09:00
committed by Ron Evans
parent 7aca814954
commit 5293d3e5f0
3 changed files with 51 additions and 30 deletions
+5
View File
@@ -424,6 +424,11 @@ func (e CANRxBufferElement) Data() []byte {
return e.DB[:CANDlcToLength(e.DLC, e.FDF)]
}
// Length returns its actual length.
func (e CANRxBufferElement) Length() byte {
return CANDlcToLength(e.DLC, e.FDF)
}
// CANDlcToLength() converts a DLC value to its actual length.
func CANDlcToLength(dlc byte, isFD bool) byte {
length := dlc