Faster company id table

Following up on the [loose end from the initial
PR](https://github.com/google/bumble/pull/207#discussion_r1278015116),
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.
This commit is contained in:
Marshall Pierce
2023-08-03 10:06:02 -06:00
parent 0301b1a999
commit e2c1ad5342
11 changed files with 2921 additions and 129 deletions

View File

@@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use bumble::{wrapper, wrapper::transport::Transport};
use bumble::wrapper::transport::Transport;
use nix::sys::stat::Mode;
use pyo3::prelude::*;
use pyo3::PyResult;
#[pyo3_asyncio::tokio::test]
async fn fifo_transport_can_open() -> PyResult<()> {
@@ -29,9 +29,3 @@ async fn fifo_transport_can_open() -> PyResult<()> {
Ok(())
}
#[pyo3_asyncio::tokio::test]
async fn company_ids() -> PyResult<()> {
assert!(wrapper::assigned_numbers::COMPANY_IDS.len() > 2000);
Ok(())
}