cpp-performance

Installation
SKILL.md

C++ Performance

Use this skill when C++ code may pay avoidable runtime cost: copies that could be references or moves, allocations that could be hoisted or reserved, move-enabling operations that the compiler will silently downgrade to copies, or library calls that have a cheaper equivalent with identical semantics.

The goal is to remove waste that does not change observable behavior: every expensive copy has a justification, every move actually moves, every container and string operation uses the cheapest correct form, and every type that participates in moves or containers is noexcept where the standard library rewards it.

UTILITY SKILL. INVOKES: read-only file access for supplied targets; no other tools or skills. FOR SINGLE OPERATIONS: use for focused copy/allocation review, move-semantics correctness, noexcept audit, or hot-path tuning.

The clang-tidy performance-* checks are the canonical catalog this skill encodes, plus a small set of cost-relevant checks from the modernize-*, bugprone-*, readability-*, and clang-analyzer-* namespaces (see Related Checks Outside The performance-* Namespace); cite the matching check name in findings so the reader can cross-reference and optionally automate the fix.

Scope

  • Use this skill for: unnecessary copies (value parameters, copy-initialized locals, range-for loop variables, implicit conversions in range-for), broken or pointless std::move (move of const, move of trivially-copyable, move into a const-ref sink, missing std::move on a copy-assigned local, const locals that block automatic move on return), move constructors that copy a base or member, missing noexcept on move constructor / move assignment / swap / iter_swap / destructor, inefficient container growth (push_back/emplace_back in a loop without reserve), inefficient string building (operator+ chains instead of +=/append), STL free-function algorithms on associative containers that have a method form, std::endl where '\n' suffices, float-to-double promotion in C math functions, oversized enum underlying types, integer-to-pointer casts that lose provenance, redundant string/string_view conversions, single-character string-literal arguments to find/+= family, and out-of-line defaulted destructors that block trivial destructibility.
  • Use it also for the closely-related cost checks in other namespaces: emplace vs insert-of-temporary (modernize-use-emplace), pass-by-value-and-move constructors (modernize-pass-by-value), the erase-remove idiom (bugprone-inaccurate-erase), empty() vs size() == 0 (readability-container-size-empty), contains() vs count/find (readability-container-contains), redundant c_str()/data() (readability-redundant-string-cstr), and struct padding (clang-analyzer-optin.performance.Padding).
  • Apply it to API signatures (by-value vs by-const-ref vs by-value-and-move), data-member and return-value move flow, type definitions that go into standard containers, and tight loops where per-iteration cost multiplies.
  • Keep the review centered on runtime cost with preserved semantics. The performance fix must be a behavior-preserving transformation; if a cheaper form changes observable behavior, lifetime, or exception guarantees, it is out of scope as a pure performance change.

DO NOT USE FOR:

Installs
3
GitHub Stars
2
First Seen
Jun 28, 2026