From ef6bd7d96336426f951c4636e232cdb855ef3d04 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Mon, 6 Jul 2015 08:43:37 -0700 Subject: [PATCH] Tighten-up code in set_next() to use an entry pointer rather than indexing. --- Objects/setobject.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Objects/setobject.c b/Objects/setobject.c index 307f19ef0f4..9753c8d22f4 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -518,20 +518,22 @@ set_next(PySetObject *so, Py_ssize_t *pos_ptr, setentry **entry_ptr) { Py_ssize_t i; Py_ssize_t mask; - setentry *table; + setentry *entry; assert (PyAnySet_Check(so)); i = *pos_ptr; assert(i >= 0); - table = so->table; mask = so->mask; - while (i <= mask && (table[i].key == NULL || table[i].key == dummy)) + entry = &so->table[i]; + while (i <= mask && (entry->key == NULL || entry->key == dummy)) { i++; + entry++; + } *pos_ptr = i+1; if (i > mask) return 0; - assert(table[i].key != NULL); - *entry_ptr = &table[i]; + assert(entry != NULL); + *entry_ptr = entry; return 1; }