summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorFredrik Lundh <fredrik@pythonware.com>2006-05-22 17:12:58 (GMT)
committerFredrik Lundh <fredrik@pythonware.com>2006-05-22 17:12:58 (GMT)
commit8a8e05a2b9c629827827295a7bd76494aed41b72 (patch)
tree16a684efaec310a8bd650509ab40c2e979a32e55 /Include
parentf1d60a53845d2efeccdb61bebf6ee8df94df16d4 (diff)
downloadcpython-8a8e05a2b9c629827827295a7bd76494aed41b72.zip
cpython-8a8e05a2b9c629827827295a7bd76494aed41b72.tar.gz
cpython-8a8e05a2b9c629827827295a7bd76494aed41b72.tar.bz2
needforspeed: use memcpy for "long" strings; use a better algorithm
for long repeats.
Diffstat (limited to 'Include')
-rw-r--r--Include/unicodeobject.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h
index 7917c68..c0036bf 100644
--- a/Include/unicodeobject.h
+++ b/Include/unicodeobject.h
@@ -352,14 +352,19 @@ 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\
- {int i; Py_UNICODE *t = (target); const Py_UNICODE *s = (source);\
- for (i = 0; i < (length); i++) t[i] = s[i];\
+ {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_FILL(target, value, length) do\
- {int i; Py_UNICODE *t = (target); Py_UNICODE v = (value);\
- for (i = 0; i < (length); i++) t[i] = v;\
+ {Py_ssize_t i_; Py_UNICODE *t_ = (target); Py_UNICODE v_ = (value);\
+ for (i_ = 0; i_ < (length); i_++) t_[i_] = v_;\
} while (0)
#define Py_UNICODE_MATCH(string, offset, substring)\