mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
do not create memo objects since we'll just throw them away
This commit is contained in:
parent
d04bcf94da
commit
ee453a1ea1
2 changed files with 11 additions and 9 deletions
|
@ -19,6 +19,14 @@ module ActionDispatch
|
||||||
end
|
end
|
||||||
|
|
||||||
def simulate(string)
|
def simulate(string)
|
||||||
|
ms = memos(string) { return }
|
||||||
|
MatchData.new(ms)
|
||||||
|
end
|
||||||
|
|
||||||
|
alias :=~ :simulate
|
||||||
|
alias :match :simulate
|
||||||
|
|
||||||
|
def memos(string)
|
||||||
input = StringScanner.new(string)
|
input = StringScanner.new(string)
|
||||||
state = [0]
|
state = [0]
|
||||||
while sym = input.scan(%r([/.?]|[^/.?]+))
|
while sym = input.scan(%r([/.?]|[^/.?]+))
|
||||||
|
@ -29,15 +37,10 @@ module ActionDispatch
|
||||||
tt.accepting? s
|
tt.accepting? s
|
||||||
}
|
}
|
||||||
|
|
||||||
return if acceptance_states.empty?
|
return yield if acceptance_states.empty?
|
||||||
|
|
||||||
memos = acceptance_states.flat_map { |x| tt.memo(x) }.compact
|
acceptance_states.flat_map { |x| tt.memo(x) }.compact
|
||||||
|
|
||||||
MatchData.new(memos)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
alias :=~ :simulate
|
|
||||||
alias :match :simulate
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -121,8 +121,7 @@ module ActionDispatch
|
||||||
|
|
||||||
def filter_routes(path)
|
def filter_routes(path)
|
||||||
return [] unless ast
|
return [] unless ast
|
||||||
data = simulator.match(path)
|
simulator.memos(path) { [] }
|
||||||
data ? data.memos : []
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_routes env
|
def find_routes env
|
||||||
|
|
Loading…
Reference in a new issue