Linear scaling for the local energy in quantum Monte Carlo