Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Array(list) covers all necessary cases $ irb 2.0.0p0 :001 > Array(nil) => [] 2.0.0p0 :002 > Array(:foo) => [:foo] 2.0.0p0 :003 > Array([:foo,:bar]) => [:foo, :bar] * Array(list) is considerably faster than list.flatten.compact $ time ruby -e "100000.times { [nil].flatten.compact; [:foo].flatten.compact; [[:foo, :bar]].flatten.compact }" real 0m0.465s user 0m0.461s sys 0m0.003s $ time ruby -e "100000.times { Array(nil); Array(:foo); Array([:foo, :bar]) }" real 0m0.117s user 0m0.113s sys 0m0.003s
- Loading branch information