From ed741d4ff0e79c89ba77906eb9417025c3935c71 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Sun, 18 Jan 2015 21:25:15 -0800 Subject: [PATCH] A hybrid of and-masking and a conditional-set-to-zero produce even faster search loop. --- Objects/setobject.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Objects/setobject.c b/Objects/setobject.c index f865d1c5f9a..ddf6822519b 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -671,7 +671,8 @@ set_pop(PySetObject *so) while ((entry = &so->table[i])->key == NULL || entry->key==dummy) { i++; - i &= so->mask; + if (i > so->mask) + i = 0; } key = entry->key; entry->key = dummy;