[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Performance problem with 0-based arrays
- From: Andrea <andrea.l.vitali@...>
- Date: Mon, 23 Nov 2020 13:42:21 -0800
Question: why a re-hash is wrong when assigning a nil?
We do want the table to shrink when it becomes less populated.
If you dis-allow this, then tables would only grow...
On Mon, Nov 23, 2020 at 11:26 PM Luiz Henrique de Figueiredo wrote:
It seems to me that the issue, if any, is creating new entries in a
table, not assigning nils.
When nil is assigned to a non-existing key, a table rehash may be triggered as if a new element was inserted.
This behaviour is obviously wrong.
Table rehashing is a very expensive operation, so it's worth adding a check on nil here.
Nothing should be done if nil is assigned to a non-existing key.