Extra debug checks in dictmerge
Former-commit-id: 839b2a151e6bad67017de87d7a637359f6ae63d1
This commit is contained in:
parent
afabc8a87e
commit
4ddc516382
10
src/dict.cpp
10
src/dict.cpp
@ -190,6 +190,7 @@ int dictMerge(dict *dst, dict *src)
|
||||
return DICT_OK;
|
||||
}
|
||||
|
||||
size_t expectedSize = dictSize(src) + dictSize(dst);
|
||||
if (dictSize(src) > dictSize(dst))
|
||||
{
|
||||
std::swap(*dst, *src);
|
||||
@ -197,11 +198,19 @@ int dictMerge(dict *dst, dict *src)
|
||||
}
|
||||
|
||||
if (!dictIsRehashing(dst) && !dictIsRehashing(src))
|
||||
{
|
||||
if (dst->ht[0].size >= src->ht[0].size)
|
||||
{
|
||||
dst->ht[1] = dst->ht[0];
|
||||
dst->ht[0] = src->ht[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
dst->ht[1] = src->ht[0];
|
||||
}
|
||||
_dictReset(&src->ht[0]);
|
||||
dst->rehashidx = 0;
|
||||
assert((dictSize(src)+dictSize(dst)) == expectedSize);
|
||||
return DICT_OK;
|
||||
}
|
||||
|
||||
@ -229,6 +238,7 @@ int dictMerge(dict *dst, dict *src)
|
||||
}
|
||||
}
|
||||
}
|
||||
assert((dictSize(src)+dictSize(dst)) == expectedSize);
|
||||
return DICT_OK;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user