aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/journey/gtg/transition_table.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-04-01 16:00:16 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-04-01 16:00:16 -0700
commit5fa65f94b8c16019d2ddd55f2e59b1bf1c87db89 (patch)
tree43dc3620f772bdc827aa5e2d4794453bb36035f7 /actionpack/lib/action_dispatch/journey/gtg/transition_table.rb
parent9aa7c25c28325f62815b6625bdfcc6dd7565165b (diff)
parent6c6dc329f8ca87304bce3be79f4d1172219d07ad (diff)
downloadrails-5fa65f94b8c16019d2ddd55f2e59b1bf1c87db89.tar.gz
rails-5fa65f94b8c16019d2ddd55f2e59b1bf1c87db89.tar.bz2
rails-5fa65f94b8c16019d2ddd55f2e59b1bf1c87db89.zip
Merge branch 'rmc'
* rmc: push move_string in to `move` combine move_regexp and move_string so we only loop over states once do not create memo objects since we'll just throw them away only ask if `t` is empty once.
Diffstat (limited to 'actionpack/lib/action_dispatch/journey/gtg/transition_table.rb')
-rw-r--r--actionpack/lib/action_dispatch/journey/gtg/transition_table.rb34
1 files changed, 13 insertions, 21 deletions
diff --git a/actionpack/lib/action_dispatch/journey/gtg/transition_table.rb b/actionpack/lib/action_dispatch/journey/gtg/transition_table.rb
index e6212b1ee2..990d2127ee 100644
--- a/actionpack/lib/action_dispatch/journey/gtg/transition_table.rb
+++ b/actionpack/lib/action_dispatch/journey/gtg/transition_table.rb
@@ -40,7 +40,19 @@ module ActionDispatch
end
def move(t, a)
- move_string(t, a).concat(move_regexp(t, a))
+ return [] if t.empty?
+
+ regexps = []
+
+ t.map { |s|
+ if states = @regexp_states[s]
+ regexps.concat states.map { |re, v| re === a ? v : nil }
+ end
+
+ if states = @string_states[s]
+ states[a]
+ end
+ }.compact.concat regexps
end
def as_json(options = nil)
@@ -139,26 +151,6 @@ module ActionDispatch
raise ArgumentError, 'unknown symbol: %s' % sym.class
end
end
-
- def move_regexp(t, a)
- return [] if t.empty?
-
- t.flat_map { |s|
- if states = @regexp_states[s]
- states.map { |re, v| re === a ? v : nil }
- end
- }.compact.uniq
- end
-
- def move_string(t, a)
- return [] if t.empty?
-
- t.map do |s|
- if states = @string_states[s]
- states[a]
- end
- end.compact
- end
end
end
end