[Python-checkins] cpython: Make sure the dummy percentage calculation won't overflow.
raymond.hettinger
python-checkins at python.org
Sat Jul 4 20:28:39 CEST 2015
https://hg.python.org/cpython/rev/9ac2169463b7
changeset: 96799:9ac2169463b7
user: Raymond Hettinger <python at rcn.com>
date: Sat Jul 04 11:28:35 2015 -0700
summary:
Make sure the dummy percentage calculation won't overflow.
files:
Objects/setobject.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Objects/setobject.c b/Objects/setobject.c
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -1506,8 +1506,8 @@
if (PyErr_Occurred())
return -1;
}
- /* If more than 1/5 are dummies, then resize them away. */
- if ((so->fill - so->used) * 5 < so->mask)
+ /* If more than 1/4th are dummies, then resize them away. */
+ if ((size_t)(so->fill - so->used) <= (size_t)so->mask / 4)
return 0;
return set_table_resize(so, so->used);
}
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list