aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-04-01 15:56:23 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-04-01 15:56:23 -0700
commit0e53d11b1fa9712270402afce771402c45fdd645 (patch)
treee3fa18acf43498f53bb3dc8cdbc8565802f8f956
parentee453a1ea1e35a0ef2f9f65a135c9e5d090b3dd2 (diff)
downloadrails-0e53d11b1fa9712270402afce771402c45fdd645.tar.gz
rails-0e53d11b1fa9712270402afce771402c45fdd645.tar.bz2
rails-0e53d11b1fa9712270402afce771402c45fdd645.zip
combine move_regexp and move_string so we only loop over states once
-rw-r--r--actionpack/lib/action_dispatch/journey/gtg/transition_table.rb15
1 files changed, 6 insertions, 9 deletions
diff --git a/actionpack/lib/action_dispatch/journey/gtg/transition_table.rb b/actionpack/lib/action_dispatch/journey/gtg/transition_table.rb
index 53c47f4696..821b510b9e 100644
--- a/actionpack/lib/action_dispatch/journey/gtg/transition_table.rb
+++ b/actionpack/lib/action_dispatch/journey/gtg/transition_table.rb
@@ -41,7 +41,7 @@ module ActionDispatch
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 @@ module ActionDispatch
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