mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Add _PyUnicodeWriter_WriteSubstring() function
Write a function to enable more optimizations: * If the substring is the whole string and overallocation is disabled, just keep a reference to the string, don't copy characters * Avoid a call to the expensive _PyUnicode_FindMaxChar() function when possible
This commit is contained in:
parent
4489e927a6
commit
cfc4c13b04
4 changed files with 57 additions and 21 deletions
|
@ -940,6 +940,15 @@ _PyUnicodeWriter_WriteStr(_PyUnicodeWriter *writer,
|
|||
PyObject *str /* Unicode string */
|
||||
);
|
||||
|
||||
/* Append a substring of a Unicode string.
|
||||
Return 0 on success, raise an exception and return -1 on error. */
|
||||
PyAPI_FUNC(int)
|
||||
_PyUnicodeWriter_WriteSubstring(_PyUnicodeWriter *writer,
|
||||
PyObject *str, /* Unicode string */
|
||||
Py_ssize_t start,
|
||||
Py_ssize_t end
|
||||
);
|
||||
|
||||
/* Append a latin1-encoded byte string.
|
||||
Return 0 on success, raise an exception and return -1 on error. */
|
||||
PyAPI_FUNC(int)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue