summaryrefslogtreecommitdiffstats
path: root/Objects/listobject.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-03-12 08:04:00 (GMT)
committerRaymond Hettinger <python@rcn.com>2004-03-12 08:04:00 (GMT)
commitc1e4f9dd92a2b63b26b06035f8c8ee1a5eb52ab3 (patch)
tree9bac712f5696672bf2817eeda0b515e9aa891653 /Objects/listobject.c
parent989ddc0709e98c1a5b3480e0843cf7896fd2909e (diff)
downloadcpython-c1e4f9dd92a2b63b26b06035f8c8ee1a5eb52ab3.zip
cpython-c1e4f9dd92a2b63b26b06035f8c8ee1a5eb52ab3.tar.gz
cpython-c1e4f9dd92a2b63b26b06035f8c8ee1a5eb52ab3.tar.bz2
Use a new macro, PySequence_Fast_ITEMS to factor out code common to
three recent optimizations. Aside from reducing code volume, it increases readability.
Diffstat (limited to 'Objects/listobject.c')
-rw-r--r--Objects/listobject.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 2f2097d..78def29 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -491,12 +491,7 @@ list_ass_slice(PyListObject *a, int ilow, int ihigh, PyObject *v)
if(v_as_SF == NULL)
return -1;
n = PySequence_Fast_GET_SIZE(v_as_SF);
- if (PyList_Check(v_as_SF))
- vitem = ((PyListObject *)v_as_SF)->ob_item;
- else {
- assert (PyTuple_Check(v_as_SF));
- vitem = ((PyTupleObject *)v_as_SF)->ob_item;
- }
+ vitem = _PySequence_Fast_ITEMS(v_as_SF);
}
if (ilow < 0)
ilow = 0;
@@ -691,12 +686,7 @@ listextend_internal(PyListObject *self, PyObject *b)
}
/* populate the end of self with b's items */
- if (PyList_Check(b))
- src = ((PyListObject *)b)->ob_item;
- else {
- assert (PyTuple_Check(b));
- src = ((PyTupleObject *)b)->ob_item;
- }
+ src = _PySequence_Fast_ITEMS(b);
dest = self->ob_item + selflen;
for (i = 0; i < blen; i++) {
PyObject *o = src[i];
@@ -2571,10 +2561,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
PyMem_MALLOC(slicelength*sizeof(PyObject*));
selfitems = self->ob_item;
- if (PyList_Check(seq))
- seqitems = ((PyListObject *)seq)->ob_item;
- else
- seqitems = ((PyTupleObject *)seq)->ob_item;
+ seqitems = _PySequence_Fast_ITEMS(seq);
for (cur = start, i = 0; i < slicelength;
cur += step, i++) {
garbage[i] = selfitems[cur];