mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #39494 from jonathanhefner/pathparser-lazy-regex
Lazily build path regex in PathParser
This commit is contained in:
commit
d8d32f2535
2 changed files with 4 additions and 5 deletions
|
@ -36,10 +36,6 @@ module ActionView
|
||||||
end
|
end
|
||||||
|
|
||||||
class PathParser # :nodoc:
|
class PathParser # :nodoc:
|
||||||
def initialize
|
|
||||||
@regex = build_path_regex
|
|
||||||
end
|
|
||||||
|
|
||||||
def build_path_regex
|
def build_path_regex
|
||||||
handlers = Template::Handlers.extensions.map { |x| Regexp.escape(x) }.join("|")
|
handlers = Template::Handlers.extensions.map { |x| Regexp.escape(x) }.join("|")
|
||||||
formats = Template::Types.symbols.map { |x| Regexp.escape(x) }.join("|")
|
formats = Template::Types.symbols.map { |x| Regexp.escape(x) }.join("|")
|
||||||
|
@ -60,6 +56,7 @@ module ActionView
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse(path)
|
def parse(path)
|
||||||
|
@regex ||= build_path_regex
|
||||||
match = @regex.match(path)
|
match = @regex.match(path)
|
||||||
{
|
{
|
||||||
prefix: match[:prefix] || "",
|
prefix: match[:prefix] || "",
|
||||||
|
|
|
@ -77,7 +77,9 @@ module ApplicationTests
|
||||||
source
|
source
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
ActionView::Template.register_template_handler(:rubby, RubbyHandler)
|
ActiveSupport.on_load :action_view do
|
||||||
|
ActionView::Template.register_template_handler(:rubby, RubbyHandler)
|
||||||
|
end
|
||||||
RUBY
|
RUBY
|
||||||
|
|
||||||
get "/"
|
get "/"
|
||||||
|
|
Loading…
Reference in a new issue