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

tidy: enable performance checks #2505

Merged
merged 1 commit into from
Nov 28, 2023
Merged

tidy: enable performance checks #2505

merged 1 commit into from
Nov 28, 2023

Commits on Nov 28, 2023

  1. tidy: enable performance checks

    With the exception of performance-no-int-to-ptr, this change enables
    clang tidy's performance-based lints.
    
    The changes made are as follows, in no particular order.
    
    - Avoid std::endl. std::endl is confusing because it also flushes the
      buffer, which is often undesirable. Instead, we should just use a newline
      character.
    - When possible, declare variables as `const T&` instead of `T`, since
      it avoids a copy.
    - When possible, use `std::move` to avoid a copy. However, if the type
      is trivially copyable, `std::move` does nothing and hence should be
      removed. Furthermore, if the variable to be moved is constant,
      `std::move` simply copies, and so `std::move` is confusing and should
      be removed. Finally, if the variable is moved, but the function
      parameter type is `const T&`, then a move is unnecessary, and again,
      it should be removed.
    - When using `push_back` in a loop, we should reserve up front for
      better performance.
    - When concatenating strings, either we should `std::move()` the
      strings, or use `string::append`. Otherwise, we pay the price of
      creating temporary strings, instead of just pushing to a single
      string.
    - Trivial destructors should be declared with `= default` to allow more
      aggressive compiler optimizations.
    Riolku committed Nov 28, 2023
    Configuration menu
    Copy the full SHA
    fc7c404 View commit details
    Browse the repository at this point in the history