bluetooth icon indicating copy to clipboard operation
bluetooth copied to clipboard

Improve UUID

Open bartmeuris opened this issue 2 years ago • 0 comments

Updated the ParseUUID so it can handle both upper and lower-case hex numbers, added simple test-cases.

Also sped up the UUID.String() by using a strings.Builder and added a benchmark.

This is the difference on my PC when I temporarily had both:

go test -bench=^BenchmarkUUIDToString -benchmem      
goos: windows
goarch: amd64
pkg: tinygo.org/x/bluetooth
cpu: AMD Ryzen 9 3900X 12-Core Processor
BenchmarkUUIDToString-24                10256830              114.4 ns/op             48 B/op          1 allocs/op
BenchmarkUUIDToStringSlow-24              585391               1899 ns/op            944 B/op         67 allocs/op
PASS
ok      tinygo.org/x/bluetooth  2.732s

BenchmarkUUIDToStringSlow is the old implementation, BenchmarkUUIDToString the updated-one in this PR

bartmeuris avatar Jul 01 '22 17:07 bartmeuris