Before implementing data structures or algorithms, analyze allocation patterns and optimize for common cases. Key strategies:

  1. Use fixed-size arrays for known small collections: ```rust // Before pub fn all() -> Vec<&’static str> { vec![“namespace”, “class”, …] }

// After pub const fn all() -> [&’static str; 15] { [“namespace”, “class”, …] } ```

  1. Leverage specialized data structures to avoid allocations:
  2. Profile before optimizing:

The goal is to minimize allocations in hot paths while keeping code maintainable. Always validate optimizations with benchmarks and profiles.