summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-04-14 17:22:47 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-04-14 17:22:47 (GMT)
commit77282cb4f8d6988587102343e5e8169554095aa5 (patch)
treefee833e3a9e905ecdbc49fbd9b44cf10bf2f2640 /Objects
parentd92e078c8d17e66c09f8e279f3efcab6932303a2 (diff)
downloadcpython-77282cb4f8d6988587102343e5e8169554095aa5.zip
cpython-77282cb4f8d6988587102343e5e8169554095aa5.tar.gz
cpython-77282cb4f8d6988587102343e5e8169554095aa5.tar.bz2
Cleanup PyUnicode_Contains()
* No need to double-check that strings are ready: test already done by PyUnicode_FromObject() * Remove useless kind variable (use kind1 instead)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 17a19db..748fcc7 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -10532,7 +10532,7 @@ int
PyUnicode_Contains(PyObject *container, PyObject *element)
{
PyObject *str, *sub;
- int kind1, kind2, kind;
+ int kind1, kind2;
void *buf1, *buf2;
Py_ssize_t len1, len2;
int result;
@@ -10551,23 +10551,18 @@ PyUnicode_Contains(PyObject *container, PyObject *element)
Py_DECREF(sub);
return -1;
}
- if (PyUnicode_READY(sub) == -1 || PyUnicode_READY(str) == -1) {
- Py_DECREF(sub);
- Py_DECREF(str);
- }
kind1 = PyUnicode_KIND(str);
kind2 = PyUnicode_KIND(sub);
- kind = kind1;
buf1 = PyUnicode_DATA(str);
buf2 = PyUnicode_DATA(sub);
- if (kind2 != kind) {
- if (kind2 > kind) {
+ if (kind2 != kind1) {
+ if (kind2 > kind1) {
Py_DECREF(sub);
Py_DECREF(str);
return 0;
}
- buf2 = _PyUnicode_AsKind(sub, kind);
+ buf2 = _PyUnicode_AsKind(sub, kind1);
}
if (!buf2) {
Py_DECREF(sub);
@@ -10577,7 +10572,7 @@ PyUnicode_Contains(PyObject *container, PyObject *element)
len1 = PyUnicode_GET_LENGTH(str);
len2 = PyUnicode_GET_LENGTH(sub);
- switch (kind) {
+ switch (kind1) {
case PyUnicode_1BYTE_KIND:
result = ucs1lib_find(buf1, len1, buf2, len2, 0) != -1;
break;
@@ -10595,7 +10590,7 @@ PyUnicode_Contains(PyObject *container, PyObject *element)
Py_DECREF(str);
Py_DECREF(sub);
- if (kind2 != kind)
+ if (kind2 != kind1)
PyMem_Free(buf2);
return result;