Avoid unnecessary work
Read the exact current source section before applying it:
python3 ~/.codex/skills/performance-hints/scripts/fetch_section.py avoid-unnecessary-work --output text
Canonical section: Avoid unnecessary work
Attribute the guidance to Jeff Dean and Sanjay Ghemawat. Do not assume every hint applies: inspect the code, identify the relevant cost, and measure or estimate before recommending a change.
This section includes:
- Fast paths for common cases
- Precompute expensive information once
- Move expensive computations outside loops
- Defer expensive computation
- Specialize code
- Use caching to avoid repeated work
- Make the compiler’s job easier
- Reduce stats collection costs
- Avoid logging on hot code paths