lib/string_metric/levenshtein.rb in string_metric-0.1.3 vs lib/string_metric/levenshtein.rb in string_metric-0.1.4

- old
+ new

@@ -6,10 +6,11 @@ require_relative "levenshtein/iterative_with_full_matrix" require_relative "levenshtein/recursive" require_relative "levenshtein/trie_node" require_relative "levenshtein/trie_radix_tree" require_relative "levenshtein/trie_radix_tree_ext" +require_relative "levenshtein/iterative_with_two_matrix_rows_ext" if RUBY_ENGINE == "ruby" module StringMetric # Levenshtein Distance implementation # # @see https://en.wikipedia.org/wiki/Levenshtein_distance @@ -21,10 +22,14 @@ recursive: Recursive, two_matrix_rows: IterativeWithTwoMatrixRows, two_matrix_rows_v2: IterativeWithTwoMatrixRowsOptimized } + if RUBY_ENGINE == "ruby" + STRATEGIES[:two_matrix_rows_ext] = IterativeWithTwoMatrixRowsExt + end + # Levenshtein Distance of two strings # # @param from [String] the first string # @param to [String] the second string # @param options [Hash] options @@ -51,10 +56,10 @@ module_function :distance # Currently the default strategy is set to IterativeWithTwoMatrixRows def default_strategy if RUBY_ENGINE == "ruby" - pick_strategy(:two_matrix_rows_v2) + pick_strategy(:two_matrix_rows_ext) else pick_strategy(:two_matrix_rows) end end module_function :default_strategy