Efficient evaluation of the Coulomb force in density-functional theory calculations