aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/journey/visitors.rb
Commit message (Collapse)AuthorAgeFilesLines
* Remove all Journey constant from public APIRafael Mendonça França2016-10-261-1/+3
| | | | | | There were never public API only there by mistake. [ci skip]
* applies remaining conventions across the projectXavier Noria2016-08-061-2/+2
|
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-18/+18
|
* applies new string literal convention in actionpack/libXavier Noria2016-08-061-1/+1
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* File encoding is defaulted to utf-8 in Ruby >= 2.1Akira Matsuda2015-09-181-2/+0
|
* drop object allocation during routes setupAaron Patterson2015-08-171-41/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit introduces a functional Path AST visitor and implements `each` on the AST in terms of the functional visitor. The functional visitor doesn't maintain state, so we only need to allocate one of them. Given this benchmark route file: ```ruby require 'action_pack' require 'action_dispatch' route_set = ActionDispatch::Routing::RouteSet.new routes = ActionDispatch::Routing::Mapper.new route_set ObjectSpace::AllocationTracer.setup(%i{path line type}) result = ObjectSpace::AllocationTracer.trace do 500.times{|i| routes.resource :omglol } end result.find_all { |k,v| k.first =~ /git\/rails/ }.sort_by { |k,v| v.first }.each { |k,v| p k => v } ``` node.rb line 17 was in our top 3 allocation spot: ``` {["/Users/aaron/git/rails/actionpack/lib/action_dispatch/journey/nodes/node.rb", 17, :T_OBJECT]=>[31526, 0, 28329, 0, 2, 1123160]} {["/Users/aaron/git/rails/actionpack/lib/action_dispatch/routing/mapper.rb", 2080, :T_IMEMO]=>[34002, 0, 30563, 0, 2, 1211480]} {["/Users/aaron/git/rails/actionpack/lib/action_dispatch/routing/mapper.rb", 2071, :T_IMEMO]=>[121934, 1, 109608, 0, 7, 4344400]} ``` This commit eliminates allocations at that place.
* reuse path formatter from the non-optimized path.Aaron Patterson2014-05-211-29/+2
| | | | | The optimized and non-optimized path share more code now without significant performance degretation
* remove dead codeAaron Patterson2014-05-201-57/+0
|
* translate AST to a formatter before url generationAaron Patterson2014-05-201-0/+70
|
* prepopulate the dispatch cache so we don't need the ThreadSafe cache.Aaron Patterson2014-05-201-7/+9
|
* make the each visitor top-down left-rightAaron Patterson2014-05-201-1/+1
|
* fix escaping in generationAaron Patterson2014-05-191-1/+7
|
* Revert "Rewrite journey routes formatter for performance"Aaron Patterson2014-05-191-28/+23
| | | | | | | | | | This reverts commit 5c224de9e110763ec7a0f01f5b604bcf81f40bfb. Conflicts: actionpack/lib/action_dispatch/journey/visitors.rb 5c224de9e110763ec7a0f01f5b604bcf81f40bfb introduced a bug in the formatter. This commit includes a regression test.
* Make URL escaping more consistentAndrew White2014-04-201-4/+17
| | | | | | | | | | | | | | | | | | | | | | 1. Escape '%' characters in URLs - only unescaped data should be passed to URL helpers 2. Add an `escape_segment` helper to `Router::Utils` that escapes '/' characters 3. Use `escape_segment` rather than `escape_fragment` in optimized URL generation 4. Use `escape_segment` rather than `escape_path` in URL generation For point 4 there are two exceptions. Firstly, when a route uses wildcard segments (e.g. *foo) then we use `escape_path` as the value may contain '/' characters. This means that wildcard routes can't be optimized. Secondly, if a `:controller` segment is used in the path then this uses `escape_path` as the controller may be namespaced. Fixes #14629, #14636 and #14070.
* Use a custom route vistor for optimized route generationAndrew White2014-01-051-4/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using a Regexp to replace dynamic segments in a path string is fraught with difficulty and can lead to odd edge cases like #13349. Since we already have a parsed representation of the path it makes sense to use that to generate an array of segments that can be used to build an optimized route's path quickly. Tests on a simple route (e.g. /posts/:id) show a speedup of 35%: https://gist.github.com/pixeltrix/8261932 Calculating ------------------------------------- Current Helper: 5274 i/100ms New Helper: 8050 i/100ms ------------------------------------------------- Current Helper: 79263.6 (±3.7%) i/s - 395550 in 4.997252s New Helper: 153464.5 (±4.9%) i/s - 772800 in 5.047834s Tests on a more complex route show even an greater performance boost: https://gist.github.com/pixeltrix/8261957 Calculating ------------------------------------- Current Helper: 2367 i/100ms New Helper: 5382 i/100ms ------------------------------------------------- Current Helper: 29506.0 (±3.2%) i/s - 149121 in 5.059294s New Helper: 78815.5 (±4.1%) i/s - 398268 in 5.062161s It also has the added benefit of fixing the edge cases described above. Fixes #13349
* Replace global Hash with TS::Cache.thedarkone2013-09-281-1/+4
|
* No need the else clauseRafael Mendonça França2013-09-241-2/+0
|
* Use join to concat the both side of the ASTRafael Mendonça França2013-09-241-1/+2
| | | | Onf of the sides can be nil and it will raise a Conversion error
* Rewrite journey routes formatter for performanceBogdan Gusiev2013-08-281-23/+23
|
* store a symbol directly inside DISPATCH_CACHE for extra roflscaleCharlie Somerville2013-06-301-1/+1
|
* Use custom visitor class for optimized url helpersAndrew White2013-03-031-0/+8
| | | | | | | | Rather than trying to use gsub to remove the optional route segments, which will fail with nested optional segments, use a custom visitor class that returns a empty string for group nodes. Closes #9524
* update AD::Journey to follow Rails coding conventionsFrancesco Rodriguez2012-12-201-92/+95
|
* :nodoc: Journey because is not part of the public API [ci skip]Francesco Rodriguez2012-12-191-7/+5
|
* Integrate Journey into Action DispatchAndrew White2012-12-191-0/+188
Move the Journey code underneath the ActionDispatch namespace so that we don't pollute the global namespace with names that may be used for models. Fixes rails/journey#49.