1. 31 7月, 2015 4 次提交
    • S
      Use delete_if instead of each; delete(key) · 22f59240
      schneems 提交于
      It is slightly faster:
      
      ```
      Calculating -------------------------------------
              each; delete    35.166k i/100ms
                 delete_if    36.416k i/100ms
      -------------------------------------------------
              each; delete    478.026k (± 8.5%) i/s -      2.391M
                 delete_if    485.123k (± 7.9%) i/s -      2.440M
      ```
      22f59240
    • S
      Remove (another) array allocation · 61dae882
      schneems 提交于
      We don't always need an array when generating a url with the formatter. We can be lazy about allocating the `missing_keys` array. This saves us:
      
      35,606 bytes and 889 objects per request
      61dae882
    • S
      Remove array allocation · 4d2ccc11
      schneems 提交于
      THe only reason we were allocating an array is to get the "missing_keys" variable in scope of the error message generator. Guess what? Arrays kinda take up a lot of memory, so by replacing that with a nil, we save:
      
      35,303 bytes and 886 objects per request
      4d2ccc11
    • S
      Avoid calling to_s on nil in journey/formatter · bff61ba2
      schneems 提交于
      When `defaults[key]` in `generate` in the journey formatter is called, it often returns a `nil` when we call `to_s` on a nil, it allocates an empty string. We can skip this check when the default value is nil.
      
      This change buys us 35,431 bytes of memory and 887 fewer objects per request.
      
      Thanks to @matthewd for help with the readability
      bff61ba2
  2. 30 7月, 2015 2 次提交
    • S
      Speed up journey missing_keys · 097ec6fb
      schneems 提交于
      Most routes have a `route.path.requirements[key]` of `/[-_.a-zA-Z0-9]+\/[-_.a-zA-Z0-9]+/` yet every time this method is called a new regex is generated on the fly with `/\A#{DEFAULT_INPUT}\Z/`. OBJECT ALLOCATIONS BLERG!
      
      This change uses a special module that implements `===` so it can be used in a case statement to pull out the default input. When this happens, we use a pre-generated regex.
      
      This change buys us 1,643,465 bytes of memory and 7,990 fewer objects per request.
      097ec6fb
    • S
      Speed up journey extract_parameterized_parts · 9b825881
      schneems 提交于
      Micro optimization: `reverse.drop_while` is slower than `reverse_each.drop_while`. This doesn't save any object allocations.
      
      Second, `keys_to_keep` is typically a very small array. The operation `parameterized_parts.keys - keys_to_keep` actually allocates two arrays. It is quicker (I benchmarked) to iterate over each and check inclusion in array manually.
      
      This change buys us 1774 fewer objects per request
      9b825881
  3. 08 4月, 2015 1 次提交
    • Y
      sort_by instead of sort · a77de098
      Yang Bo 提交于
      it is avoid sort errot within different and mixed keys.
      used `sort_by` + `block` to list parameter by keys.
      keep minimum changes
      a77de098
  4. 04 1月, 2015 1 次提交
  5. 23 11月, 2014 2 次提交
  6. 21 10月, 2014 1 次提交
  7. 18 7月, 2014 1 次提交
    • A
      `recall` should be `path_parameters`, also make it required · 932386be
      Aaron Patterson 提交于
      "recall" is a terrible name.  This variable contains the parameters that
      we got from the path (e.g. for "/posts/1" it has :controller => "posts",
      :id => "1").  Since it contains the parameters we got from the path,
      "path_parameters" is a better name.  We always pass path_parameters to
      `generate`, so lets make it required.
      932386be
  8. 23 5月, 2014 3 次提交
  9. 22 5月, 2014 2 次提交
  10. 21 5月, 2014 1 次提交
  11. 01 3月, 2014 1 次提交
  12. 05 1月, 2014 1 次提交
    • A
      Show full route constraints in error message · 892c5395
      Andrew White 提交于
      When an optimized helper fails to generate, show the full route constraints
      in the error message. Previously it would only show the contraints that were
      required as part of the path.
      
      Fixes #13592
      892c5395
  13. 16 7月, 2013 1 次提交
    • A
      Skip Rack applications and redirects when generating urls · 1555a180
      Andrew White 提交于
      When generating an unnamed url (i.e. using `url_for` with an options
      hash) we should skip anything other than standard Rails routes otherwise
      it will match the first mounted application or redirect and generate a
      url with query parameters rather than raising an error if the options
      hash doesn't match any defined routes.
      
      Fixes #8018
      1555a180
  14. 09 5月, 2013 1 次提交
  15. 09 4月, 2013 1 次提交
  16. 16 1月, 2013 1 次提交
    • A
      Raise correct exception now Journey is integrated. · db06d128
      Andrew White 提交于
      Now that Journey has been integrated into ActionDispatch we can raise
      the exception ActionController::UrlGenerationError directly rather than
      raising the internal Journey::Router::RoutingError and then have
      ActionDispatch::Routing::RouteSet#generate re-raise the exception.
      db06d128
  17. 03 1月, 2013 1 次提交
  18. 02 1月, 2013 1 次提交
  19. 21 12月, 2012 1 次提交
  20. 20 12月, 2012 2 次提交