Optimize buffer swapping