When selecting a data structure to store a set of unique elements, in which a common operation will be to check if an element is part of that data structure, the a Set comes to mind as the ideal, minimal choice.
One downside of Set is that it's slower than a Hash when checking for present of an element, even though Set's implementation is backed by a Hash.
This PR documents the difference in performance profile between Hash#has_key? and Set#include? to help users that need to check for an association in performance critical paths.
When selecting a data structure to store a set of unique elements, in which a common operation will be to check if an element is part of that data structure, the a
Set
comes to mind as the ideal, minimal choice.One downside of
Set
is that it's slower than aHash
when checking for present of an element, even thoughSet
's implementation is backed by aHash
.This PR documents the difference in performance profile between
Hash#has_key?
andSet#include?
to help users that need to check for an association in performance critical paths.