Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1025 from schveiguy/fix13748
Browse files Browse the repository at this point in the history
Fix issue 13748 -- benchmark druntime/benchmark/aabench/string.d fails
  • Loading branch information
rainers committed Nov 19, 2014
2 parents 03de104 + 57e3887 commit 6c6c431
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/rt/aaA.d
Expand Up @@ -218,23 +218,37 @@ body

auto nodes = ++aa.impl.nodes;
//printf("length = %d, nodes = %d\n", aa.a.buckets.length, nodes);

// update cache if necessary
if (i < aa.impl.firstUsedBucket)
aa.impl.firstUsedBucket = i;
if (nodes > aa.impl.buckets.length * 4)
{
//printf("rehash\n");
_aaRehash(aa,keyti);
}
else
{
// update cache if necessary
if (i < aa.impl.firstUsedBucket)
aa.impl.firstUsedBucket = i;
}
}

Lret:
return cast(void*)(e + 1) + aligntsize(keytitsize);
}

// bug 13748
pure nothrow unittest
{
int[int] aa;
// make all values go into the last bucket (int hash is simply the int)
foreach(i; 0..16)
{
aa[3 + i * 4] = 1;
assert(aa.keys.length == i+1);
}

// now force a rehash, but with a different value
aa[0] = 1;
assert(aa.keys.length == 17);
}


/*************************************************
* Get pointer to value in associative array indexed by key.
Expand Down

0 comments on commit 6c6c431

Please sign in to comment.