Update buffer only when needed.