Copy get_common_len from Distance.jl