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

Faster company id table #237

Merged
merged 1 commit into from
Aug 9, 2023
Merged

Conversation

marshallpierce
Copy link
Contributor

@marshallpierce marshallpierce commented Aug 3, 2023

Following up on the loose end from the initial PR, we can avoid accessing the Python company id map at runtime by doing code gen ahead of time.

Using an example to do the code gen avoids even the small build slowdown from invoking the code gen logic in build.rs, but more importantly, means that it's still a totally boring normal build that won't require any IDE setup, etc, to work for everyone. Since the company ID list changes rarely, and there's a test to ensure it always matches, this seems like a good trade.

@marshallpierce marshallpierce marked this pull request as ready for review August 3, 2023 16:13
rust/examples/gen_assigned_numbers.rs Outdated Show resolved Hide resolved
Following up on the [loose end from the initial
PR](google#207 (comment)),
we can avoid accessing the Python company id map at runtime by doing
code gen ahead of time.

Using an example to do the code gen avoids even the small build slowdown
from invoking the code gen logic in build.rs, but more importantly,
means that it's still a totally boring normal build that won't require
any IDE setup, etc, to work for everyone. Since the company ID list
changes rarely, and there's a test to ensure it always matches, this
seems like a good trade.
@uael
Copy link
Contributor

uael commented Aug 8, 2023

Do you think it's worth generating an enum and impl Display?

@uael
Copy link
Contributor

uael commented Aug 8, 2023

Or using a static array instead? As it looks like indexes are sequential

@marshallpierce
Copy link
Contributor Author

I'm not familiar enough with the ways of the Bluetooth SIG to know if counting on them being sequential, and complete, is reasonable. Maybe? 🤷

We certainly could make an enum. I'm not sure what the use case would be, but that could be a lack of imagination on my end. Do you have something in mind? Presumably, some code that wants to refer to, say, PlantChoir Inc. (???) specifically without having 1945 as a magic constant in their code? In other words, when going from company name (in source code) to a number, an enum makes sense, but my current use is only number -> company name.

@uael
Copy link
Contributor

uael commented Aug 8, 2023

Ok SGTM I was just wondering 😅

@barbibulle barbibulle merged commit 53d66bc into google:main Aug 9, 2023
11 checks passed
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.

None yet

5 participants