Describe a time you had to optimize a piece of code for a resource-constrained environment or a high-performance system.