You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
eastl::unordered_set is implemented behind the scenes as a eastl::hashtable
The various eastl colleciton classes support the method reserve to reserve enough space to hold data that is intended to be inserted, to prevent repeated allocations.
In most cases, a check is made to see if any allocations would actually need to be done, and if not, the method exits without making any changes.
eastl::hashtable on the otherhand blindly always calls rehash, which calls DoRehash, which always does allocations, copies and frees, even if the amount of buckets that were calculated as being needed is the same as before.
It also will happily accept reducing the amount of buckets if reserve was passed in a size that was less than the current size.
I herefore raise:
Why does reserve() not bail out if the size provided is less than or equal to the current size.
Why does reserve() also not bail out if, while the size provided is greater than the current size, there is no change required to the number of buckets, and therefore no reallocations required.
I have opened this as a question as opposed to providing a pull request, as I am primarily a Java developer and therefore don't consider myself knowledgeable with EASTL enough to know if there is a valid reason for this behaviour to exist.
The text was updated successfully, but these errors were encountered:
eastl::unordered_set is implemented behind the scenes as a eastl::hashtable
The various eastl colleciton classes support the method reserve to reserve enough space to hold data that is intended to be inserted, to prevent repeated allocations.
In most cases, a check is made to see if any allocations would actually need to be done, and if not, the method exits without making any changes.
eastl::hashtable on the otherhand blindly always calls rehash, which calls DoRehash, which always does allocations, copies and frees, even if the amount of buckets that were calculated as being needed is the same as before.
It also will happily accept reducing the amount of buckets if reserve was passed in a size that was less than the current size.
I herefore raise:
I have opened this as a question as opposed to providing a pull request, as I am primarily a Java developer and therefore don't consider myself knowledgeable with EASTL enough to know if there is a valid reason for this behaviour to exist.
The text was updated successfully, but these errors were encountered: