not sure if this optimisation is necessary, or if gcc knows how to do it