Describe a scenario where you had to optimize code to run under strict memory or latency constraints at Chaos Industries.