mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
bpo-47070: Add _PyBytes_Repeat() (GH-31999)
Use it where appropriate: the repeat functions of `array.array`, `bytes`, `bytearray`, and `str`.
This commit is contained in:
parent
86384cf83f
commit
850687df47
6 changed files with 81 additions and 103 deletions
|
@ -33,6 +33,19 @@ _PyBytes_ReverseFind(const char *haystack, Py_ssize_t len_haystack,
|
|||
const char *needle, Py_ssize_t len_needle,
|
||||
Py_ssize_t offset);
|
||||
|
||||
|
||||
/** Helper function to implement the repeat and inplace repeat methods on a buffer
|
||||
*
|
||||
* len_dest is assumed to be an integer multiple of len_src.
|
||||
* If src equals dest, then assume the operation is inplace.
|
||||
*
|
||||
* This method repeately doubles the number of bytes copied to reduce
|
||||
* the number of invocations of memcpy.
|
||||
*/
|
||||
PyAPI_FUNC(void)
|
||||
_PyBytes_Repeat(char* dest, Py_ssize_t len_dest,
|
||||
const char* src, Py_ssize_t len_src);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue