fixes #186: optimise loops over static, integral ranges