Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate passing string to define callback. #22598

Merged
merged 1 commit into from Dec 16, 2015

Conversation

@yui-knk
Copy link
Contributor

@yui-knk yui-knk commented Dec 15, 2015

No description provided.

@rails-bot
Copy link

@rails-bot rails-bot commented Dec 15, 2015

r? @pixeltrix

(@rails-bot has picked a reviewer for you, use r? to override)

@yui-knk
Copy link
Contributor Author

@yui-knk yui-knk commented Dec 15, 2015

ref #22460

@claudiob
Copy link
Member

@claudiob claudiob commented Dec 15, 2015

👍 @yui-knk 😄

As part of this commit, I think you should also remove this documentation.

@rafaelfranca
rafaelfranca reviewed Dec 15, 2015
View changes
actionpack/lib/abstract_controller/callbacks.rb Outdated
@@ -48,7 +48,8 @@ def _normalize_callback_options(options)

def _normalize_callback_option(options, from, to) # :nodoc:
if from = options[from]
from = Array(from).map {|o| "action_name == '#{o}'"}.join(" || ")
_from = Array(from).map(&:to_s)

This comment has been minimized.

@rafaelfranca

rafaelfranca Dec 15, 2015
Member

Maybe we should create a Set so the performance of include? is better?

This comment has been minimized.

@nateberkopec

nateberkopec Dec 15, 2015
Contributor

Hm, looks like creating Sets is too slow. Here's a benchmark. With an Array of 10 elements, creating a Set and then calling #include? is 5x slower than creating an Array and calling #include?

This comment has been minimized.

@rafaelfranca

rafaelfranca Dec 15, 2015
Member

Yes, creating sets is slow but we are creating only once and we are calling include on every request so it may be worth using Set here.

This comment has been minimized.

@rafaelfranca

rafaelfranca Dec 15, 2015
Member

Per the size of the Array it will not matter.

This comment has been minimized.

@yui-knk

yui-knk Dec 16, 2015
Author Contributor

@nateberkopec Thanks for your help

$ ruby creating_set.rb
Calculating -------------------------------------
         set include    45.093k i/100ms
       array include    15.519k i/100ms
-------------------------------------------------
         set include    713.458k (± 5.0%) i/s -      3.562M
       array include    182.015k (± 4.3%) i/s -    915.621k

Comparison:
         set include:   713457.8 i/s
       array include:   182014.8 i/s - 3.92x slower
@yui-knk yui-knk force-pushed the yui-knk:deprecate_string_callback branch to 21f4017 Dec 16, 2015
@yui-knk
Copy link
Contributor Author

@yui-knk yui-knk commented Dec 16, 2015

@rafaelfranca I updatd 😍

rafaelfranca added a commit that referenced this pull request Dec 16, 2015
Deprecate passing string to define callback.
@rafaelfranca rafaelfranca merged commit b7a7e82 into rails:master Dec 16, 2015
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@kamipo kamipo added the activesupport label Jan 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

7 participants
You can’t perform that action at this time.