mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-03 02:27:48 +00:00
machine: avoid bytes package in USB logic
This greatly cuts down on compile time (by about 5x for small programs) and also makes the program a whole lot smaller. Overall it cuts down `make smoke-test` in the drivers repository by half (from 160s to 80s). This will probably also fix the timeout issue in the Playground: https://github.com/tinygo-org/playground/issues/7
This commit is contained in:
committed by
Ron Evans
parent
c698e99880
commit
4ee7bf00e1
+12
-13
@@ -3,7 +3,6 @@
|
||||
package machine
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"runtime/volatile"
|
||||
)
|
||||
@@ -348,18 +347,18 @@ const cdcSize = iadDescriptorSize +
|
||||
|
||||
// Bytes returns CDCDescriptor data.
|
||||
func (d CDCDescriptor) Bytes() []byte {
|
||||
buf := bytes.NewBuffer(make([]byte, 0))
|
||||
buf.Write(d.iad.Bytes())
|
||||
buf.Write(d.cif.Bytes())
|
||||
buf.Write(d.header.Bytes())
|
||||
buf.Write(d.controlManagement.Bytes())
|
||||
buf.Write(d.functionalDescriptor.Bytes())
|
||||
buf.Write(d.callManagement.Bytes())
|
||||
buf.Write(d.cifin.Bytes())
|
||||
buf.Write(d.dif.Bytes())
|
||||
buf.Write(d.out.Bytes())
|
||||
buf.Write(d.in.Bytes())
|
||||
return buf.Bytes()
|
||||
var buf []byte
|
||||
buf = append(buf, d.iad.Bytes()...)
|
||||
buf = append(buf, d.cif.Bytes()...)
|
||||
buf = append(buf, d.header.Bytes()...)
|
||||
buf = append(buf, d.controlManagement.Bytes()...)
|
||||
buf = append(buf, d.functionalDescriptor.Bytes()...)
|
||||
buf = append(buf, d.callManagement.Bytes()...)
|
||||
buf = append(buf, d.cifin.Bytes()...)
|
||||
buf = append(buf, d.dif.Bytes()...)
|
||||
buf = append(buf, d.out.Bytes()...)
|
||||
buf = append(buf, d.in.Bytes()...)
|
||||
return buf
|
||||
}
|
||||
|
||||
// MSCDescriptor is not used yet.
|
||||
|
||||
Reference in New Issue
Block a user