Optimize truncation algorithm.