mirror of
https://github.com/python/cpython.git
synced 2025-09-14 20:56:06 +00:00
needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
and use it for string copy operations. this gives a 20% speedup on some string benchmarks.
This commit is contained in:
parent
5e9d6cfbda
commit
80f8e80c15
3 changed files with 60 additions and 46 deletions
|
@ -357,15 +357,8 @@ typedef PY_UNICODE_TYPE Py_UNICODE;
|
|||
Py_UNICODE_ISDIGIT(ch) || \
|
||||
Py_UNICODE_ISNUMERIC(ch))
|
||||
|
||||
/* memcpy has a considerable setup overhead on many platforms; use a
|
||||
loop for short strings (the "16" below is pretty arbitary) */
|
||||
#define Py_UNICODE_COPY(target, source, length) do\
|
||||
{Py_ssize_t i_; Py_UNICODE *t_ = (target); const Py_UNICODE *s_ = (source);\
|
||||
if (length > 16)\
|
||||
memcpy(t_, s_, (length)*sizeof(Py_UNICODE));\
|
||||
else\
|
||||
for (i_ = 0; i_ < (length); i_++) t_[i_] = s_[i_];\
|
||||
} while (0)
|
||||
#define Py_UNICODE_COPY(target, source, length) \
|
||||
Py_MEMCPY((target), (source), (length)*sizeof(Py_UNICODE))
|
||||
|
||||
#define Py_UNICODE_FILL(target, value, length) do\
|
||||
{Py_ssize_t i_; Py_UNICODE *t_ = (target); Py_UNICODE v_ = (value);\
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue