Rafael Mendonça França
5b23e31771
Merge pull request #15836 from DNNX/router-swap-select-sort
...
Replace x.sort_by!.select! with x.select!.sort_by!
2014-06-24 14:26:29 -03:00
Yves Senn
9ac1ce11ad
:nodoc: all
does not remove the constants from the API. [ci skip]
...
Need to add individual `:nodoc:` for nested classes / modules to completely
remove the constants from the API.
2014-06-24 14:16:29 +02:00
Viktar Basharymau
8ee785a17f
Replace x.sort_by!.select! with x.select!.sort_by!
...
The latter has the same speed as the former in the worst case
and faster in general, because it is always better to sort less items.
Unfortunately, `routes.select!{...}.sort_by!{...}` is not possible here
because `select!` returns `nil`, so select! and sort! must be done
in two steps.
2014-06-20 17:16:11 +03:00
Matthew Draper
edc0f27197
Merge pull request #15537 from tgxworld/fix_state_leak
...
Fix state leak.
2014-06-20 14:53:20 +09:30
Aaron Patterson
ef686a6095
add both branches to the only_path conditional
2014-06-19 14:19:44 -07:00
Viktar Basharymau
453cd7b617
Relpace =~ Regexp.new str
with .include? str
in AC::Base#_valid_action_name?
...
Because it is more natural way to test substring inclusion. Also, in
this particular case it is much faster.
In general, using `Regexp.new str` for such kind of things is dangerous.
The string must be escaped, unless you know what you're doing. Example:
Regexp.new "\\" # HELLO WINDOWS
# RegexpError: too short escape sequence: /\/
The right way to do this is escape the string
Regexp.new Regexp.escape "\\"
# => /\\/
Here is the benchmark showing how faster `include?` call is.
```
require 'benchmark/ips'
Benchmark.ips do |x|
x.report('include?') { !"index".to_s.include? File::SEPARATOR }
x.report(' !~ ') { "index" !~ Regexp.new(File::SEPARATOR) }
end
__END__
Calculating -------------------------------------
include? 75754 i/100ms
!~ 21089 i/100ms
-------------------------------------------------
include? 3172882.3 (±4.5%) i/s - 15832586 in 5.000659s
!~ 322918.8 (±8.6%) i/s - 1602764 in 4.999509s
```
Extra `.to_s` call is needed to handle the case when `action_name` is
`nil`. If it is omitted, some tests fail.
2014-06-19 18:39:58 +03:00
Aditya Kapoor
7ddaf10fcb
[ci skip] /javascript/ ~> JavaScript
2014-06-17 02:07:07 +05:30
Yves Senn
92de6d4c35
Merge pull request #15744 from mmozuras/special_keys_set
...
Change Http::Cache::SPECIAL_KEYS from Array to Set
2014-06-16 08:35:00 +02:00
Yves Senn
4ce99ae347
Merge pull request #15743 from tgxworld/remove_unused_parameters
...
Remove unused parameter.
2014-06-16 08:32:59 +02:00
Mindaugas Mozūras
e312381589
Change Http::Cache::SPECIAL_KEYS from Array to Set
...
Slightly improves performance, for example, a simple benchmark:
```ruby
require 'benchmark/ips'
require 'set'
SPECIAL_KEYS = %w[extras no-cache max-age public must-revalidate]
SPECIAL_KEYS_SET = Set.new(SPECIAL_KEYS)
directive = 'must-revalidate'
Benchmark.ips do |x|
x.report('array') { SPECIAL_KEYS.include?(directive) }
x.report('set') { SPECIAL_KEYS_SET.include?(directive) }
end
```
Output:
```
-------------------------------------
array 67926 i/100ms
set 74054 i/100ms
-------------------------------------
array 2318423.4 (±2.8%) i/s - 11615346 in 5.014899s
set 3387981.8 (±4.7%) i/s - 16958366 in 5.019355s
```
2014-06-15 22:26:15 +03:00
Mindaugas Mozūras
aaa7b6bf2c
Remove unused param 'separators' from RouteSet#build_path
2014-06-15 22:01:34 +03:00
Guo Xiang Tan
70312d224a
Remove unused parameter.
2014-06-15 10:36:46 -07:00
Larry Lv
4a9d4c85c3
Fix request's path_info when a rack app mounted at '/'.
...
Fixes issue #15511 .
2014-06-14 04:57:33 +08:00
Matthew Draper
497def80b5
Merge pull request #15692 from sromano/falseClass
...
ActionController::Parameters#require now accepts FalseClass values
2014-06-14 06:14:19 +09:30
Sergio Romano
540d153531
ActionController::Parameters#require now accepts FalseClass values
...
Fixes #15685 .
2014-06-13 14:42:38 -03:00
Rafael Mendonça França
0bfdf40870
Merge pull request #15682 from tgxworld/controller_test_process
...
Set flash in test session when necessary.
2014-06-13 11:24:03 -03:00
Larry Lv
fdb1059795
Fix parsed token value with header Authorization token=
.
2014-06-13 16:29:15 +08:00
Guillermo Iguaran
a62001c542
Set the status before of setting the response body
...
The 401 status should be set first because setting the response body in
a live controller also closes the response to further changes.
Fixes #14229 .
2014-06-13 02:25:26 -05:00
Guo Xiang Tan
be46586e69
Set flash in test session when necessary.
...
`to_session_value` returns nil when empty.
2014-06-12 20:48:21 -07:00
Aaron Patterson
d7f780c304
only check named_host? once in normalize_host
2014-06-12 11:22:38 -07:00
Aaron Patterson
977a2f38c7
lookup subdomain from the options hash once, defaulting to true
...
if the subdomain wasn't specified, it's the same as if specifying
:subdomain as `true`, so we can default the value to `true` safely.
2014-06-12 10:10:31 -07:00
Aaron Patterson
160f56c21b
only extract domain from the options hash once
2014-06-12 10:05:26 -07:00
Aaron Patterson
21c626133a
reduce calls to named_host?
...
`normalize_host` already calls `named_host?`, so there is no reason to
test `named_host?` again in the `extract_domain` method.
2014-06-12 10:01:35 -07:00
Aaron Patterson
caf1bfccc6
use Ruby for mocking
2014-06-12 09:19:59 -07:00
Juanito Fatas
26ef4fce41
Removed warning actionpack url.rb
...
Before:
/Users/Juan/dev/rails/actionpack/lib/action_dispatch/http/url.rb:95: warning: shadowing outer local variable - port
After:
No warning
2014-06-12 14:45:37 +08:00
Aaron Patterson
df3c78296a
remove useless to_param call
...
extract_subdomain always returns a string, and to_param calls to_s on a
string
2014-06-11 15:32:52 -07:00
Aaron Patterson
ba1c685d8c
only look up the subdomain once
2014-06-11 15:30:12 -07:00
Aaron Patterson
3327dd462f
scheme should contain one or more characters
2014-06-11 15:28:04 -07:00
Aaron Patterson
a64914de4c
pull the port out of the options hash once
2014-06-11 15:01:30 -07:00
Aaron Patterson
ed37698596
remove useless nil check
...
irb(main):004:0> /foo/ !~ nil
=> true
irb(main):005:0> /foo/ !~ 'bar'
=> true
irb(main):006:0> /foo/ !~ 'foo'
=> false
2014-06-11 14:40:45 -07:00
Aaron Patterson
3aabac5b0d
these methods are always called with a tld_parameter
...
remove the default parameter since the methods are always called with a
parameter
2014-06-11 14:32:30 -07:00
Aaron Patterson
1b14bff81a
rm same_host?
. The same conditional is two lines down.
2014-06-11 14:09:54 -07:00
Aaron Patterson
3654f1b7e4
Revert "rm same_host?
. The same conditional is two lines down."
...
This reverts commit 79469b4b0c
.
2014-06-11 14:05:04 -07:00
Aaron Patterson
79469b4b0c
rm same_host?
. The same conditional is two lines down.
2014-06-11 13:56:00 -07:00
Rafael Mendonça França
e7580db1f3
Merge pull request #15648 from kuldeepaggarwal/fix-warnings
...
remove warnings
2014-06-11 16:02:59 -03:00
Kuldeep Aggarwal
fca73eeb87
remove warnings
...
warning: assigned but unused variable - scope_called, path and strexp
2014-06-12 00:27:58 +05:30
Aaron Patterson
85ba47e3f1
cache host on the stack so we only look it up once
2014-06-11 11:48:39 -07:00
Aaron Patterson
ec1caddb7f
only pull :protocol from the options hash once
2014-06-11 11:42:49 -07:00
Aaron Patterson
aaaff369da
cache protocol on the stack to reduce options hash lookups
2014-06-11 11:36:50 -07:00
Aaron Patterson
1c432d1af1
eliminate nil checks in normalize_port
2014-06-11 11:33:36 -07:00
Aaron Patterson
a6f30bea06
reduce hash lookups and disconnect normalize_port from the options hash
2014-06-11 11:33:35 -07:00
Yves Senn
71f99be858
Merge pull request #15545 from zuhao/refactor_actionpack_assert_select_test
...
Restore test deliveries for ActionMailer.
2014-06-08 15:55:20 +02:00
Matthew Draper
6a89850dfe
Handle client disconnect during live streaming
...
.. even when the producer is blocked for a write.
2014-06-08 07:21:14 +09:30
Xavier Noria
f84d081faf
adds some details to the rationale of converted_arrays [ci skip]
2014-06-07 13:30:03 +02:00
Xavier Noria
f712f89961
adds a regression test for the strong params converted arrays cache
...
This is a regression test for 29844dd.
2014-06-07 13:19:16 +02:00
Xavier Noria
1ecada20d1
Revert "Convert StrongParameters cache to a hash. This fixes an unbounded"
...
We cannot cache keys because arrays are mutable. We rather want to cache
the arrays. This behaviour is tailor-made for the usage pattern strongs
params is designed for.
In a forthcoming commit I am going to add a test that covers why we need
to cache by value.
Every strong params instance has a live span of a request, the cache goes
away with the object. Since strong params have such a concrete intention,
it would be interesting to see if there are actually any real-world use
cases that are an actual leak, one that practically may matter.
I am not convinced that the theoretical leak has any practical consequences,
but if it can be shown there are, then I believe we should either get rid of
the cache (which is an optimization), or else wipe it in the mutating API.
This reverts commit e63be2769c
.
2014-06-07 13:19:16 +02:00
Akshay Vishnoi
b6760d8f14
[ci skip] Fix capitalization
2014-06-07 14:23:27 +05:30
Aaron Patterson
092f74080c
remove another wasteful AS::SafeBuffer allocation
2014-06-06 12:06:58 -07:00
Aaron Patterson
e9f215d9f2
eliminate wasteful AS::SafeBuffer allocation
2014-06-06 12:06:04 -07:00
Zuhao Wan
64edb6cb19
Restore test deliveries for ActionMailer.
2014-06-07 00:18:50 +08:00