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

Speed up the fast path for assert_eq! and assert_ne! #57815

Merged
merged 1 commit into from
Feb 13, 2019

Commits on Jan 21, 2019

  1. Speed up the fast path for assert_eq! and assert_ne!

    Currently, the panic!() calls directly borrow the value bindings. This
    causes those bindings to always be initialized, i.e. they're initialized
    even before the values are even compared. This causes noticeable
    overhead in what should be a really cheap operation.
    
    By performing a reborrow of the value in the call to panic!(), we allow
    LLVM to optimize that code, so that the extra borrow only happens in the
    error case.
    
    We could achieve the same result by dereferencing the values passed to
    panic!(), as the format machinery borrows them anyway, but this causes
    assertions to fail to compile if one of the values is unsized, i.e. it
    would be a breaking change.
    dotdash committed Jan 21, 2019
    Configuration menu
    Copy the full SHA
    5a7cd84 View commit details
    Browse the repository at this point in the history