[Python-checkins] CVS: python/dist/src/Objects dictobject.c,2.93,2.94
Tim Peters
tim_one@users.sourceforge.net
Thu, 24 May 2001 09:26:42 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv6271/python/dist/src/Objects
Modified Files:
dictobject.c
Log Message:
dictresize(): Rebuild small tables if there are any dummies, not just if
they're entirely full. Not a question of correctness, but of temporarily
misplaced common sense.
Index: dictobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/dictobject.c,v
retrieving revision 2.93
retrieving revision 2.94
diff -C2 -r2.93 -r2.94
*** dictobject.c 2001/05/23 23:33:57 2.93
--- dictobject.c 2001/05/24 16:26:40 2.94
***************
*** 428,441 ****
if (newsize == MINSIZE) {
! /* Either a large table is shrinking, or we can't get any
! smaller. */
newtable = mp->ma_smalltable;
if (newtable == oldtable) {
! if (mp->ma_fill < mp->ma_size)
return 0;
! /* The small table is entirely full. We're not
! going to resise it, but need to rebuild it
! anyway to purge old dummy entries. */
! assert(mp->ma_fill > mp->ma_used); /* a dummy exists */
memcpy(small_copy, oldtable, sizeof(small_copy));
oldtable = small_copy;
--- 428,445 ----
if (newsize == MINSIZE) {
! /* A large table is shrinking, or we can't get any smaller. */
newtable = mp->ma_smalltable;
if (newtable == oldtable) {
! if (mp->ma_fill == mp->ma_used) {
! /* No dummies, so no point doing anything. */
return 0;
! }
! /* We're not going to resize it, but rebuild the
! table anyway to purge old dummy entries.
! Subtle: This is *necessary* if fill==size,
! as lookdict needs at least one virgin slot to
! terminate failing searches. If fill < size, it's
! merely desirable, as dummies slow searches. */
! assert(mp->ma_fill > mp->ma_used);
memcpy(small_copy, oldtable, sizeof(small_copy));
oldtable = small_copy;