Actions
Feature #13884
closedReduce number of memory allocations for "and", "or" and "diff" operations on small arrays
Description
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:
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.
I tested this patch on 64 architecture and found out that in arrays with 32 elements, element search is performed faster than retrieving an element from the hash (tested on collections with 16, 32, 64 and 128 elements).
Files
Actions
Like0
Like0Like0Like0Like0Like0Like0Like0Like0