diff options
| author | Benjamin Peterson <benjamin@python.org> | 2011-11-22 15:29:32 -0500 |
|---|---|---|
| committer | Benjamin Peterson <benjamin@python.org> | 2011-11-22 15:29:32 -0500 |
| commit | 02686751931e6cd267f60c65b59744c7dff50cd2 (patch) | |
| tree | e46c65573253c586bf0c16935c8cd321b5e04053 /Objects/unicodeobject.c | |
| parent | f683700121a34e6301e50e681c20ca846db6b171 (diff) | |
| download | cpython-git-02686751931e6cd267f60c65b59744c7dff50cd2.tar.gz | |
fix compiler warning by implementing this more cleverly
Diffstat (limited to 'Objects/unicodeobject.c')
| -rw-r--r-- | Objects/unicodeobject.c | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index ff22f859e0..a7d9e1224c 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -6164,12 +6164,7 @@ PyUnicode_AsRawUnicodeEscapeString(PyObject *unicode) kind = PyUnicode_KIND(unicode); data = PyUnicode_DATA(unicode); len = PyUnicode_GET_LENGTH(unicode); - - switch(kind) { - case PyUnicode_1BYTE_KIND: expandsize = 4; break; - case PyUnicode_2BYTE_KIND: expandsize = 6; break; - case PyUnicode_4BYTE_KIND: expandsize = 10; break; - } + expandsize = kind * 2 + 2; if (len > PY_SSIZE_T_MAX / expandsize) return PyErr_NoMemory(); |
