diff options
| author | Victor Stinner <victor.stinner@gmail.com> | 2013-04-14 18:44:10 +0200 |
|---|---|---|
| committer | Victor Stinner <victor.stinner@gmail.com> | 2013-04-14 18:44:10 +0200 |
| commit | af03757d20a13b4090d06e0a198122be194aa6b0 (patch) | |
| tree | aecef262f4fc65205624efe127afa1ccac0247c5 /Objects/unicodeobject.c | |
| parent | 322cc7438c081e19d0402f53e720d6b0cd58b227 (diff) | |
| download | cpython-git-af03757d20a13b4090d06e0a198122be194aa6b0.tar.gz | |
Optimize ascii(str): don't encode/decode repr if repr is already ASCII
Diffstat (limited to 'Objects/unicodeobject.c')
| -rw-r--r-- | Objects/unicodeobject.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 99628cad72..0996afbbb8 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -6499,7 +6499,7 @@ _PyUnicode_AsASCIIString(PyObject *unicode, const char *errors) return NULL; /* Fast path: if it is an ASCII-only string, construct bytes object directly. Else defer to above function to raise the exception. */ - if (PyUnicode_MAX_CHAR_VALUE(unicode) < 128) + if (PyUnicode_IS_ASCII(unicode)) return PyBytes_FromStringAndSize(PyUnicode_DATA(unicode), PyUnicode_GET_LENGTH(unicode)); return unicode_encode_ucs1(unicode, errors, 128); |
