Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary ------- This commit is a step toward removing `cast.rs` (see RCasatta#1). This commit tweaks `cast.rs` to uniformly use `TryInto` in all configurations (not just in `#[cfg(debug_assertions)]`). Benchmark impact ---------------- Disclaimers: Benchmarking is tricky: * Confidence intervals below are relatively wide * Code changes can have indirect/unexpected impact (e.g. noise from random changes to binary code layout may be significant in microbenchmarks). This commit introduces additional checks into the relase configuration and therefore may have a performance impact. Benchmarks before this commit: $ cargo bench --features=bench | grep bench ... ...bench_qr_code_with_low_ecc ...: 18,680,806 ns/iter (+/- 147,143) ...bench_find_min_version ...: 1 ns/iter (+/- 0) ...bench_push_splitted_bytes ...: 3,754 ns/iter (+/- 48) ...bench::bench_optimize_base64 ...: 29,262 ns/iter (+/- 470) ...bench::bench_optimize_example1 ...: 1,582 ns/iter (+/- 33) Benchmarks after this commit: $ cargo bench --features=bench | grep bench ... ...bench_qr_code_with_low_ecc ...: 18,805,800 ns/iter (+/- 133,211) ...bench_find_min_version ...: 1 ns/iter (+/- 0) ...bench_push_splitted_bytes ...: 4,070 ns/iter (+/- 19) ...bench::bench_optimize_base64 ...: 36,202 ns/iter (+/- 1,069) ...bench::bench_optimize_example1 ...: 1,706 ns/iter (+/- 23) The difference is 18,805,800 ns - 18,680,806 ns = 124,994 ns. This is a slowdown of 124,994 ns / 18,805,800 ns = 0.664%. Evaluation ---------- Arguments for landing this commit: * Potential for code removal and simplification * Consistently applying correctness checks in all configurations. * This is consistent with Rust's safe-by-default approach * This is consistent with the recent change in Chromium policy which recommends against using debug-mode-only `DCHECK`s: https://chromium.googlesource.com/chromium/src/+/main/styleguide/c++/checks.md Arguments against landing this commit: * 0.664% slowdown (note the disclaimers above about micro-benchmarks) * Extra checks may increase the binary size of the code
- Loading branch information