[distance] fix unused variable warnings

 produced by clang++ with -Wextra and by VS (reported by Adam)