]> granicus.if.org Git - python/commitdiff
Convert one more division to unsigned arithmetic to speed-up deque_item().
authorRaymond Hettinger <python@rcn.com>
Sat, 28 Feb 2015 15:41:30 +0000 (07:41 -0800)
committerRaymond Hettinger <python@rcn.com>
Sat, 28 Feb 2015 15:41:30 +0000 (07:41 -0800)
Modules/_collectionsmodule.c

index 8494a47d87219bf33c4b0336798e8b98d25419a0..d12f0e8769ec01cdf7758e57cb08c8c2e0a7d709 100644 (file)
@@ -788,7 +788,9 @@ deque_item(dequeobject *deque, Py_ssize_t i)
             while (n--)
                 b = b->rightlink;
         } else {
-            n = (deque->leftindex + Py_SIZE(deque) - 1) / BLOCKLEN - n;
+            n = (Py_ssize_t)(
+                    ((unsigned)(deque->leftindex + Py_SIZE(deque) - 1))
+                    / BLOCKLEN - n);
             b = deque->rightblock;
             while (n--)
                 b = b->leftlink;