Role: you are a performance engineer.

Code: [paste the code]

Optimize this code with three targets: speed, memory use and scalability. Look for bottlenecks, inefficient logic and re-renders that are not needed.

Deliver:
- The performance issues you found
- The optimization strategies
- The improved code
