aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/journey/visitors.rb
Commit message (Collapse)AuthorAgeFilesLines
* Enable `Layout/EmptyLinesAroundAccessModifier` copRyuta Kamizono2019-06-131-3/+0
| | | | | | | | | | | We sometimes say "✂️ newline after `private`" in a code review (e.g. https://github.com/rails/rails/pull/18546#discussion_r23188776, https://github.com/rails/rails/pull/34832#discussion_r244847195). Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style `EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059). That cop and enforced style will reduce the our code review cost.
* Add `Style/RedundantFreeze` to remove redudant `.freeze`Yasuo Honda2018-09-291-1/+1
| | | | | | | | | | | | | | | | | | | | | Since Rails 6.0 will support Ruby 2.4.1 or higher `# frozen_string_literal: true` magic comment is enough to make string object frozen. This magic comment is enabled by `Style/FrozenStringLiteralComment` cop. * Exclude these files not to auto correct false positive `Regexp#freeze` - 'actionpack/lib/action_dispatch/journey/router/utils.rb' - 'activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb' It has been fixed by https://github.com/rubocop-hq/rubocop/pull/6333 Once the newer version of RuboCop released and available at Code Climate these exclude entries should be removed. * Replace `String#freeze` with `String#-@` manually if explicit frozen string objects are required - 'actionpack/test/controller/test_case_test.rb' - 'activemodel/test/cases/type/string_test.rb' - 'activesupport/lib/active_support/core_ext/string/strip.rb' - 'activesupport/test/core_ext/string_ext_test.rb' - 'railties/test/generators/actions_test.rb'
* [Action Pack] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-111-0/+1
|
* Prepare AP and AR to be frozen string friendlyKir Shatrov2017-07-061-2/+3
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* [docs] fix ActionDispatch documentationHrvoje Šimić2017-03-131-1/+1
|
* class Foo < Struct.new(:x) creates an extra unneeded anonymous classAkira Matsuda2017-01-131-1/+1
| | | | because Struct.new returns a Class, we just can give it a name and use it directly without inheriting from it
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-1/+1
|
* 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.