]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
Move insertion resize logic into set_insert_key().
authorRaymond Hettinger <python@rcn.com>
Sat, 4 Jul 2015 00:21:17 +0000 (17:21 -0700)
committerRaymond Hettinger <python@rcn.com>
Sat, 4 Jul 2015 00:21:17 +0000 (17:21 -0700)
commit15f08696096a80d026ed21164f892a661fc72e98
tree5c8b25b7c0924225da104a3ca6aa7b96df4d4bd1
parentdf418b67aba4a31ba9fc8a80372d58b82b768b72
Move insertion resize logic into set_insert_key().

Simplifies the code a little bit and does the resize check
only when a new key is added (giving a small speed up in
the case where the key already exists).

Fixes possible bug in set_merge() where the set_insert_key()
call relies on a big resize at the start to make enough room
for the keys but is vulnerable to a comparision callback that
could cause the table to shrink in the middle of the merge.

Also, changed the resize threshold from two-thirds of the
mask+1 to just two-thirds.  The plus one offset gave no
real benefit (afterall, the two-thirds mark is just a
heuristic and isn't a precise cut-off).
Objects/setobject.c