The method #_asIdentityBag is used in many places to convert
an unordered collection into an IdentityBag before applying some
operation against it. While this is a no-op for IdentityBags and
IdentitySets (returning self), it involves doing a copy of elements
from the internal dictionary when applied to Bags and Sets.
For very large collections, this adversely affects performance,
and can create many temporary objects that must be garbage-collected.
This issue arises in the query operators #select:, #reject:, #detect:, and #detect:ifNone:,
although there are other callers of #_asIdentityBag that might also
benefit by recoding to avoid the extra copy operation.
Last updated: