The previous implementation was quite slow. This leverages some of the
transcoding abilities built into Ruby 1.9 instead. It is roughly 96%
faster.
The roundtrip through UTF_8_MAC here is because ruby won't let you
transcode from UTF_8 to UTF_8. I chose the closest encoding I could
find as an intermediate.
This reverts commit 09751fdc847c25237891a8fcb0c2312e39bbe86d, reversing
changes made to 6a5ab08d21c4284a05f5e34484b18a91d4e5c50c.
This change caused a failure in
actionpack/test/abstract/callbacks_test.rb.
MiniTest 4.7.3 detects the presence of SIGINFO and stores the answer in
a constant.
It seems that MiniTest 4.7.4 changes this, and instead relies on an
info_signal method being implemented on the runner object.
In ActiveSupport::Testing::Isolation, we use ProxyTestResult to stand in
for the runner object. This object implements `method_missing`, and as
such its #info_signal method has a truthy return value. This results in
MiniTest trying to install the SIGINFO handler on platforms where
SIGINFO does not exists.
To fix, I am simply defining an explicit ProxyTestResult#info_signal
method.
callbacks in the CallbackChain, so you don't have to iterate over all
callbacks when checking for duplicates.
Benchmark results when the tests in
activerecord/test/cases/associations_test.rb were run with and without
the change:
== On master (when scanning all of the callbacks):
---------------------------------------------------------
% cumulative self self total
time seconds seconds calls ms/call ms/call name
---------------------------------------------------------
1.85 9.26 0.82 18412 0.04 0.05
ActiveSupport::Callbacks::Callback#matches?
1.22 12.32 0.54 18412 0.03 0.08
ActiveSupport::Callbacks::Callback#duplicates?
0.93 14.61 0.41 19600 0.02 0.21
ActiveSupport::Callbacks::CallbackChain#remove_duplicates
Finished tests in 1.217065s, 30.4010 tests/s, 53.4072 assertions/s.
---------------------------------------------------------
== On my branch (when using a hash to check callback duplication):
---------------------------------------------------------
% cumulative self self total
time seconds seconds calls ms/call ms/call name
---------------------------------------------------------
0.15 29.63 0.06 1188 0.05 0.72
ActiveSupport::Callbacks::CallbackChain#handle_duplicates
0.00 40.50 0.00 84 0.00 0.12
ActiveSupport::Callbacks::Callback#matches?
0.00 40.50 0.00 84 0.00 0.12
ActiveSupport::Callbacks::Callback#duplicates?
0.00 40.50 0.00 91 0.00 0.22
ActiveSupport::Callbacks::CallbackChain#scan_and_remove_duplicates
Finished tests in 1.117757s, 33.1020 tests/s, 58.1522 assertions/s.
---------------------------------------------------------
This reverts commit ebf69ab1636df74c76332c53bcd3d8494fb91b45.
`in?` must not take multiple parameters because its behavior would be
ambiguous:
# Test if "B" is included in a list of names with `"B".in?(*names)`:
names = ["BMorearty"]
"B".in?(*names) # => true
names = ["BMorearty","rubyduo"]
"B".in?(*names) # => false
Conflicts:
activesupport/lib/active_support/core_ext/object/inclusion.rb
activesupport/test/core_ext/object/inclusion_test.rb
Notes:
1) I hope nilness is a word.
2) See rationale for avoiding multiple evaluation in a comment in the patch, credit goes to @jeremy for pointing out this gotcha in the existing implementation.
3) Embeds a little joke dedicated to @pixeltrix (it could be worse! :D).
References #10347.
Add documentation and test to delegation method that make sure we're
aware that when a delegated object is not nil or false and doesn't
respond to the method it will still raise a NoMethodError exception.