Permalink
Browse files

combine move_regexp and move_string so we only loop over states once

  • Loading branch information...
1 parent ee453a1 commit 0e53d11b1fa9712270402afce771402c45fdd645 @tenderlove tenderlove committed Apr 1, 2014
Showing with 6 additions and 9 deletions.
  1. +6 −9 actionpack/lib/action_dispatch/journey/gtg/transition_table.rb
@@ -41,7 +41,7 @@ def eclosure(t)
def move(t, a)
return [] if t.empty?
- move_string(t, a).concat(move_regexp(t, a))
+ move_string(t, a)
end
def as_json(options = nil)
@@ -141,20 +141,17 @@ def states_hash_for(sym)
end
end
- def move_regexp(t, a)
- t.flat_map { |s|
+ def move_string(t, a)
+ regexps = []
+ t.map { |s|
if states = @regexp_states[s]
- states.map { |re, v| re === a ? v : nil }
+ regexps.concat states.map { |re, v| re === a ? v : nil }
end
- }.compact.uniq
- end
- def move_string(t, a)
- t.map do |s|
if states = @string_states[s]
states[a]
end
- end.compact
+ }.compact.concat regexps
end
end
end

0 comments on commit 0e53d11

Please sign in to comment.