Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve UUID #107

Merged
merged 4 commits into from
Aug 25, 2022
Merged

Improve UUID #107

merged 4 commits into from
Aug 25, 2022

Conversation

bartmeuris
Copy link
Contributor

@bartmeuris bartmeuris commented Jul 1, 2022

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

Copy link
Member

@aykevl aykevl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I would prefer the last 3 comments to be squashed into one, because the last two are really just improvements on the first of the 3.

uuid.go Show resolved Hide resolved
@deadprogram
Copy link
Member

I am going to squash/merge in the interest of getting this in!

Thanks @bartmeuris for working on it!

@deadprogram deadprogram merged commit 948ea8c into tinygo-org:dev Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants