class RuboCop::StringUtil::Jaro

def find_common_characters

def find_common_characters
  common_chars_of_shorter = Array.new(shorter.size)
  common_chars_of_longer = Array.new(longer.size)
  # In Ruby 1.9 String#chars returns Enumerator rather than Array.
  longer_chars = longer.each_char.to_a
  shorter.each_char.with_index do |shorter_char, shorter_index|
    matching_index_range(shorter_index).each do |longer_index|
      longer_char = longer_chars[longer_index]
      next unless shorter_char == longer_char
      common_chars_of_shorter[shorter_index] = shorter_char
      common_chars_of_longer[longer_index] = longer_char
      # Mark the matching character as already used
      longer_chars[longer_index] = nil
      break
    end
  end
  [common_chars_of_shorter, common_chars_of_longer].map(&:compact)
end