[Python-checkins] cpython: Add an early-out for deque_clear()

raymond.hettinger python-checkins at python.org
Wed Sep 30 07:45:11 CEST 2015


https://hg.python.org/cpython/rev/91259f061cfb
changeset: 98433:91259f061cfb
user: Raymond Hettinger <python at rcn.com>
date: Tue Sep 29 22:45:05 2015 -0700
summary:
 Add an early-out for deque_clear()
files:
 Modules/_collectionsmodule.c | 3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -595,6 +595,9 @@
 Py_ssize_t n;
 PyObject *item;
 
+ if (Py_SIZE(deque) == 0)
+ return;
+
 /* During the process of clearing a deque, decrefs can cause the
 deque to mutate. To avoid fatal confusion, we have to make the
 deque empty before clearing the blocks and never refer to
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /