Modify _PyBytes_DecodeEscapeRecode() to use _PyBytesAPI

* Don't overallocate by 400% when recode is needed: only overallocate on demand
  using _PyBytesWriter.
* Use _PyLong_DigitValue to convert hexadecimal digit to int
* Create _PyBytes_DecodeEscapeRecode() subfunction
This commit is contained in:
Victor Stinner 2015-10-14 13:32:13 +02:00
parent 1285e5c805
commit 2ec8063cc9
2 changed files with 75 additions and 59 deletions

View file

@ -65,7 +65,8 @@ PyAPI_FUNC(PyObject *) PyLong_GetInfo(void);
# error "void* different in size from int, long and long long"
#endif /* SIZEOF_VOID_P */
/* Used by Python/mystrtoul.c and _PyBytes_FromHex(). */
/* Used by Python/mystrtoul.c, _PyBytes_FromHex(),
_PyBytes_DecodeEscapeRecode(), etc. */
#ifndef Py_LIMITED_API
PyAPI_DATA(unsigned char) _PyLong_DigitValue[256];
#endif