[distance] fix unused variable warnings produced by clang++ with -Wextra and warnings by VS (reported by Adam)