summaryrefslogtreecommitdiff
path: root/c/wchar_helper_3.h
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2017-06-19 12:26:58 +0200
committerArmin Rigo <arigo@tunes.org>2017-06-19 12:26:58 +0200
commit2ac353e16081c3bdccddb900aae1a3a210b32a03 (patch)
treed94954883f3a7c26ab9e8237b86651848823c497 /c/wchar_helper_3.h
parent6ad1d85ebf0b71a48559b56fb64266606a6af8ca (diff)
downloadcffi-2ac353e16081c3bdccddb900aae1a3a210b32a03.tar.gz
Probable improvement
Diffstat (limited to 'c/wchar_helper_3.h')
-rw-r--r--c/wchar_helper_3.h10
1 files changed, 2 insertions, 8 deletions
diff --git a/c/wchar_helper_3.h b/c/wchar_helper_3.h
index c50ea2d..f15464e 100644
--- a/c/wchar_helper_3.h
+++ b/c/wchar_helper_3.h
@@ -143,13 +143,7 @@ static int _my_PyUnicode_AsChar32(PyObject *unicode,
cffi_char32_t *result,
Py_ssize_t resultlen)
{
- Py_ssize_t len = PyUnicode_GET_LENGTH(unicode);
- unsigned int kind = PyUnicode_KIND(unicode);
- void *data = PyUnicode_DATA(unicode);
- Py_ssize_t i;
-
- for (i = 0; i < len; i++)
- result[i] = PyUnicode_READ(kind, data, i);
-
+ if (PyUnicode_AsUCS4(unicode, (Py_UCS4 *)result, resultlen, 0) == NULL)
+ return -1;
return 0;
}