1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionpack/test/journey
Adam Hegyi e0eff2c3dd Memoize regex when checking missing route keys
When the route definition has parameters, we can supply a regex for
validation purposes:

    get "/a/:b" => "test#index", constraints: { b: /abc/ }, as: test

This regex is going to be used to check the supplied values during
link generation:

    test_path("abc") # check "abc" against /abc/ regex

The link generation code checks each parameter. To properly validate the
parameter, it creates a new regex with start and end of string modifiers:

    /\A#{original_regex}\Z/

This means for each link generation the code stringifies the existing
regex and creates a new one. When a new regex is created, it needs to be
compiled, for large regexes this can take quite a bit of time.

This change memoizes the generated regex for each route when constrains
are given. It also removes the RegexCaseComparator class since it is not
in use anymore.
2020-01-08 08:36:29 +01:00
..
gtg
nfa
nodes
path Memoize regex when checking missing route keys 2020-01-08 08:36:29 +01:00
route/definition Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
router Enable Performance/UnfreezeString cop 2018-09-23 08:56:55 +09:00
route_test.rb Remove Route#build as it wasn't used 2019-05-22 23:59:18 +02:00
router_test.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
routes_test.rb Use assert_empty and assert_not_empty 2018-01-25 23:32:59 -05:00