Permalink
Browse files

Replace map.flatten(1) with flat_map

  • Loading branch information...
1 parent 401787d commit b11ebf1d80e4fb124f0ce0448cea30988256da59 @sferik sferik committed Mar 1, 2014
@@ -121,9 +121,9 @@ def missing_keys(route, parts)
def possibles(cache, options, depth = 0)
cache.fetch(:___routes) { [] } + options.find_all { |pair|
cache.key?(pair)
- }.map { |pair|
+ }.flat_map { |pair|
possibles(cache[pair], options, depth + 1)
- }.flatten(1)
+ }
end
# Returns +true+ if no missing keys are present, otherwise +false+.
@@ -120,11 +120,11 @@ def states
end
def transitions
- @string_states.map { |from, hash|
+ @string_states.flat_map { |from, hash|
hash.map { |s, to| [from, s, to] }
- }.flatten(1) + @regexp_states.map { |from, hash|
+ } + @regexp_states.flat_map { |from, hash|
hash.map { |s, to| [from, s, to] }
- }.flatten(1)
+ }
end
private

0 comments on commit b11ebf1

Please sign in to comment.