I hesitated to post this on the topic of druntime because probably I will learn something new if I am totally/stupidly wrong.

In druntime/blob/master/src/rt/aaA.d Lines 553-562:

...
    auto p = aa.findSlotInsert(hash);
    if (p.deleted)
        --aa.deleted;
    // check load factor and possibly grow
    else if (++aa.used * GROW_DEN > aa.dim * GROW_NUM)
    {
        aa.grow(ti.key);
        p = aa.findSlotInsert(hash);
        assert(p.empty);
    }
...

findSlotInsert are called two times. Why not:

    if (++aa.used * GROW_DEN > aa.dim * GROW_NUM)
        aa.grow(ti.key);

    auto p = aa.findSlotInsert(hash); // only one call is enough?

    if (p.deleted)
        --aa.deleted;
...

If I am not wrong this modification will not corrupt the current state of the hash table?

Reply via email to