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

Remove calls to debug_assert #953

Closed
wants to merge 4 commits into from

Commits on May 19, 2022

  1. Replace runtime size check with compile time check

    Add a macro `const_assert` that uses some const declaration trickery to
    trigger a compile time error if a boolean expression is false.
    
    Replace runtime checks using `debug_assert_eq!` with the newly defined
    `const_asert!` macro.
    tcharding committed May 19, 2022
    Configuration menu
    Copy the full SHA
    93c4151 View commit details
    Browse the repository at this point in the history
  2. Use assert_eq for len check

    According to the Rust docs for `debug_assert` it should only be used if
    there a proved performance costs to using `assert`.
    
    Checking the length of a `BinaryHeap` is equivalent to checking the
    length of a `Vec` which is fast, therefore its unlikely that using
    `assert_eq` will have any noticeable performance costs.
    tcharding committed May 19, 2022
    Configuration menu
    Copy the full SHA
    5485e69 View commit details
    Browse the repository at this point in the history
  3. Use assert_eq for string bytes length check

    According to the Rust docs for `debug_assert` it should only be used if
    there a proved performance costs to using `assert`.
    
    Checking the length of the slice returned by `as_bytes` is fast,
    therefore its unlikely that using `assert_eq` will have any noticeable
    performance costs.
    tcharding committed May 19, 2022
    Configuration menu
    Copy the full SHA
    7f79afd View commit details
    Browse the repository at this point in the history
  4. Use assert_eq for encoded data length check

    According to the Rust docs for `debug_assert` it should only be used if
    there a proved performance costs to using `assert`.
    
    Checking the length of a vector is fast, therefore its unlikely that
    using `assert_eq` will have any noticeable performance costs.
    tcharding committed May 19, 2022
    Configuration menu
    Copy the full SHA
    15d3800 View commit details
    Browse the repository at this point in the history