Identify and eliminate duplicate computations, unnecessary object creation, and redundant function calls to improve performance. This is especially critical in memory-sensitive areas and frequently executed code paths.

Key practices:

Example from codebase:

// Before: Redundant calls
const isVisible1 = isElementVisible(element);
const isVisible2 = isElementVisible(element); // Same element, duplicate call

// After: Cache the result
const isVisible = isElementVisible(element);
// Use 'isVisible' variable in both places

// Before: Creating new array
return annotations.map(annotation => ({ ...annotation, location: absolutePath }));

// After: Modify in place when safe
annotations.forEach(annotation => annotation.location = absolutePath);
return annotations;

This optimization becomes increasingly important in hot code paths, loops, and memory-constrained environments where even small inefficiencies can compound into significant performance impacts.