diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-05-20 12:36:16 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2017-05-20 12:36:16 +0900 |
commit | 0d874b4a5a39646bbfc3e062db62a3b3ab68b47c (patch) | |
tree | 1c0862461d37e032006573b94abe7ee5cbddfae9 /activerecord/lib/active_record/relation/calculations.rb | |
parent | c01ea3e54984f8ecc698af4a701483b560d616aa (diff) | |
download | rails-0d874b4a5a39646bbfc3e062db62a3b3ab68b47c.tar.gz rails-0d874b4a5a39646bbfc3e062db62a3b3ab68b47c.tar.bz2 rails-0d874b4a5a39646bbfc3e062db62a3b3ab68b47c.zip |
Make `VALID_DIRECTIONS` to `Set`
```ruby
require "benchmark/ips"
require "set"
array = [:asc, :desc, :ASC, :DESC, "asc", "desc", "ASC", "DESC"]
set = array.to_set
item = "DESC"
Benchmark.ips do |x|
x.report "array" do
array.include?(item)
end
x.report "set" do
set.include?(item)
end
end
```
```
% ruby array_vs_set.rb
Warming up --------------------------------------
array 188.441k i/100ms
set 229.531k i/100ms
Calculating -------------------------------------
array 3.508M (± 9.0%) i/s - 17.525M in 5.043058s
set 5.134M (± 7.6%) i/s - 25.707M in 5.038921s
```
Diffstat (limited to 'activerecord/lib/active_record/relation/calculations.rb')
0 files changed, 0 insertions, 0 deletions