diff -r dd8a03e98158 Objects/setobject.c --- a/Objects/setobject.c Sun Jan 25 22:56:57 2015 +0200 +++ b/Objects/setobject.c Sun Jan 25 23:10:14 2015 +0200 @@ -196,10 +196,22 @@ set_insert_clean(PySetObject *so, PyObje size_t j; while (1) { - for (j = 0 ; j <= LINEAR_PROBES ; j++) { - entry = &table[(i + j) & mask]; - if (entry->key == NULL) - goto found_null; + i &= mask; + entry = &table[i]; + if (entry->key == NULL) + goto found_null; + if (i + LINEAR_PROBES <= mask) { + for (j = 1; j <= LINEAR_PROBES; j++) { + entry = &table[i + j]; + if (entry->key == NULL) + goto found_null; + } + } else { + for (j = 1; j <= LINEAR_PROBES; j++) { + entry = &table[(i + j) & mask]; + if (entry->key == NULL) + goto found_null; + } } perturb >>= PERTURB_SHIFT; i = i * 5 + 1 + perturb;