Apply an optimization to reduce memory allocations