[Python-checkins] cpython: Hoist the global dummy lookup out of the inner loop for set_merge().

raymond.hettinger python-checkins at python.org
Wed Aug 21 10:35:09 CEST 2013


http://hg.python.org/cpython/rev/4e79c3ae8a12
changeset:   85289:4e79c3ae8a12
user:        Raymond Hettinger <python at rcn.com>
date:        Wed Aug 21 01:34:18 2013 -0700
summary:
  Hoist the global dummy lookup out of the inner loop for set_merge().

files:
  Objects/setobject.c |  4 +++-
  1 files changed, 3 insertions(+), 1 deletions(-)


diff --git a/Objects/setobject.c b/Objects/setobject.c
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -683,6 +683,7 @@
 {
     PySetObject *other;
     PyObject *key;
+    PyObject *dummy_entry;
     Py_hash_t hash;
     Py_ssize_t i;
     setentry *entry;
@@ -702,12 +703,13 @@
        if (set_table_resize(so, (so->used + other->used)*2) != 0)
            return -1;
     }
+    dummy_entry = dummy;
     for (i = 0; i <= other->mask; i++) {
         entry = &other->table[i];
         key = entry->key;
         hash = entry->hash;
         if (key != NULL &&
-            key != dummy) {
+            key != dummy_entry) {
             Py_INCREF(key);
             if (set_insert_key(so, key, hash) == -1) {
                 Py_DECREF(key);

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list