mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
![]() [Feature #13884] Reduce number of memory allocations for "and", "or" and "diff" operations on small arrays Very often, arrays are used to filter parameters and to select interesting items from 2 collections and very often these collections are small enough, for example: ```ruby SAFE_COLUMNS = [:id, :title, :created_at] def columns @all_columns & SAFE_COLUMNS end ``` In this patch, I got rid of unnecessary memory allocations for small arrays when "and", "or" and "diff" operations are performed. name | HEAD | PATCH -----------------+------:+------: array_small_and | 0.615 | 0.263 array_small_diff | 0.676 | 0.282 array_small_or | 0.953 | 0.463 name | PATCH -----------------+------: array_small_and | 2.343 array_small_diff | 2.392 array_small_or | 2.056 name | HEAD | PATCH -----------------+------:+------: array_small_and | 1.429 | 1.005 array_small_diff | 1.493 | 0.878 array_small_or | 1.672 | 1.152 name | PATCH -----------------+------: array_small_and | 1.422 array_small_diff | 1.700 array_small_or | 1.452 Author: Dmitry Bochkarev <dimabochkarev@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60057 b2dd03c8-39d4-4d8f-98ff-823fe69b080e |
||
---|---|---|
.. | ||
fixtures | ||
pack | ||
shared | ||
allocate_spec.rb | ||
any_spec.rb | ||
append_spec.rb | ||
array_spec.rb | ||
assoc_spec.rb | ||
at_spec.rb | ||
bsearch_index_spec.rb | ||
bsearch_spec.rb | ||
clear_spec.rb | ||
clone_spec.rb | ||
collect_spec.rb | ||
combination_spec.rb | ||
compact_spec.rb | ||
comparison_spec.rb | ||
concat_spec.rb | ||
constructor_spec.rb | ||
count_spec.rb | ||
cycle_spec.rb | ||
delete_at_spec.rb | ||
delete_if_spec.rb | ||
delete_spec.rb | ||
dig_spec.rb | ||
drop_spec.rb | ||
drop_while_spec.rb | ||
dup_spec.rb | ||
each_index_spec.rb | ||
each_spec.rb | ||
element_reference_spec.rb | ||
element_set_spec.rb | ||
empty_spec.rb | ||
eql_spec.rb | ||
equal_value_spec.rb | ||
fetch_spec.rb | ||
fill_spec.rb | ||
find_index_spec.rb | ||
first_spec.rb | ||
flatten_spec.rb | ||
frozen_spec.rb | ||
hash_spec.rb | ||
include_spec.rb | ||
index_spec.rb | ||
initialize_spec.rb | ||
insert_spec.rb | ||
inspect_spec.rb | ||
intersection_spec.rb | ||
join_spec.rb | ||
keep_if_spec.rb | ||
last_spec.rb | ||
length_spec.rb | ||
map_spec.rb | ||
max_spec.rb | ||
min_spec.rb | ||
minus_spec.rb | ||
multiply_spec.rb | ||
new_spec.rb | ||
partition_spec.rb | ||
permutation_spec.rb | ||
plus_spec.rb | ||
pop_spec.rb | ||
product_spec.rb | ||
push_spec.rb | ||
rassoc_spec.rb | ||
reject_spec.rb | ||
repeated_combination_spec.rb | ||
repeated_permutation_spec.rb | ||
replace_spec.rb | ||
reverse_each_spec.rb | ||
reverse_spec.rb | ||
rindex_spec.rb | ||
rotate_spec.rb | ||
sample_spec.rb | ||
select_spec.rb | ||
shift_spec.rb | ||
shuffle_spec.rb | ||
size_spec.rb | ||
slice_spec.rb | ||
sort_by_spec.rb | ||
sort_spec.rb | ||
take_spec.rb | ||
take_while_spec.rb | ||
to_a_spec.rb | ||
to_ary_spec.rb | ||
to_h_spec.rb | ||
to_s_spec.rb | ||
transpose_spec.rb | ||
try_convert_spec.rb | ||
union_spec.rb | ||
uniq_spec.rb | ||
unshift_spec.rb | ||
values_at_spec.rb | ||
zip_spec.rb |