Skip to content

Deprecate passing string to define callback. - #22598

Merged
rafaelfranca merged 1 commit into
rails:masterfrom
yui-knk:deprecate_string_callback
Dec 16, 2015
Merged

Deprecate passing string to define callback.#22598
rafaelfranca merged 1 commit into
rails:masterfrom
yui-knk:deprecate_string_callback

Conversation

@yui-knk

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

Copy link
Copy Markdown
Contributor

No description provided.

@rails-bot

Copy link
Copy Markdown

r? @pixeltrix

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

@yui-knk

yui-knk commented Dec 15, 2015

Copy link
Copy Markdown
Contributor Author

ref #22460

@claudiob

Copy link
Copy Markdown
Member

👍 @yui-knk 😄

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per the size of the Array it will not matter.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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 deprecate_string_callback branch from 1547683 to 21f4017 Compare December 16, 2015 10:58
@yui-knk

yui-knk commented Dec 16, 2015

Copy link
Copy Markdown
Contributor Author

@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants