Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c56e0e3

Browse files
committed
Minor touchups.
1 parent 69492da commit c56e0e3

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

Objects/setobject.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
#include "structmember.h"
1212
#include "stringlib/eq.h"
1313

14-
/* This must be >= 1. */
14+
/* This must be >= 1 */
1515
#define PERTURB_SHIFT 5
16+
17+
/* This should be >= PySet_MINSIZE - 1 */
1618
#define LINEAR_PROBES 9
1719

1820
/* Object used as dummy key to fill deleted entries */
@@ -123,7 +125,7 @@ set_lookkey(PySetObject *so, PyObject *key, Py_hash_t hash)
123125
}
124126

125127
perturb >>= PERTURB_SHIFT;
126-
i = i * 5 + perturb + 1;
128+
i = i * 5 + 1 + perturb;
127129

128130
entry = &table[i & mask];
129131
if (entry->key == NULL)
@@ -187,7 +189,7 @@ set_lookkey_unicode(PySetObject *so, PyObject *key, Py_hash_t hash)
187189
}
188190

189191
perturb >>= PERTURB_SHIFT;
190-
i = i * 5 + perturb + 1;
192+
i = i * 5 + 1 + perturb;
191193

192194
entry = &table[i & mask];
193195
if (entry->key == NULL)
@@ -257,7 +259,7 @@ set_insert_clean(PySetObject *so, PyObject *key, Py_hash_t hash)
257259
goto found_null;
258260
}
259261
perturb >>= PERTURB_SHIFT;
260-
i = i * 5 + perturb + 1;
262+
i = i * 5 + 1 + perturb;
261263
}
262264
found_null:
263265
so->fill++;

0 commit comments

Comments
 (0)