summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2016-09-13 18:22:02 (GMT)
committerChristian Heimes <christian@python.org>2016-09-13 18:22:02 (GMT)
commitf051e43b22af014364e231c36489e6745993ea34 (patch)
tree7a35470d92a6a5146bfa321bda6f9024e90adc7d /Objects
parenta4d9b17b1fd0f3432c72d686c7668169e39e7119 (diff)
downloadcpython-f051e43b22af014364e231c36489e6745993ea34.zip
cpython-f051e43b22af014364e231c36489e6745993ea34.tar.gz
cpython-f051e43b22af014364e231c36489e6745993ea34.tar.bz2
Issue #28126: Replace Py_MEMCPY with memcpy(). Visual Studio can properly optimize memcpy().
Diffstat (limited to 'Objects')
-rw-r--r--Objects/abstract.c4
-rw-r--r--Objects/bytesobject.c20
-rw-r--r--Objects/stringlib/join.h6
-rw-r--r--Objects/stringlib/transmogrify.h40
-rw-r--r--Objects/unicodeobject.c32
5 files changed, 51 insertions, 51 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index 17da5c9..36f2242 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -2353,7 +2353,7 @@ _PyObject_Call_Prepend(PyObject *func,
/* use borrowed references */
stack[0] = obj;
- Py_MEMCPY(&stack[1],
+ memcpy(&stack[1],
&PyTuple_GET_ITEM(args, 0),
argcount * sizeof(PyObject *));
@@ -2428,7 +2428,7 @@ _PyStack_UnpackDict(PyObject **args, Py_ssize_t nargs, PyObject *kwargs,
}
/* Copy position arguments (borrowed references) */
- Py_MEMCPY(stack, args, nargs * sizeof(stack[0]));
+ memcpy(stack, args, nargs * sizeof(stack[0]));
kwstack = stack + nargs;
pos = i = 0;
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index 4d14451..1550083 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -120,7 +120,7 @@ PyBytes_FromStringAndSize(const char *str, Py_ssize_t size)
if (str == NULL)
return (PyObject *) op;
- Py_MEMCPY(op->ob_sval, str, size);
+ memcpy(op->ob_sval, str, size);
/* share short strings */
if (size == 1) {
characters[*str & UCHAR_MAX] = op;
@@ -163,7 +163,7 @@ PyBytes_FromString(const char *str)
return PyErr_NoMemory();
(void)PyObject_INIT_VAR(op, &PyBytes_Type, size);
op->ob_shash = -1;
- Py_MEMCPY(op->ob_sval, str, size+1);
+ memcpy(op->ob_sval, str, size+1);
/* share short strings */
if (size == 0) {
nullstring = op;
@@ -437,7 +437,7 @@ formatfloat(PyObject *v, int flags, int prec, int type,
str = _PyBytesWriter_Prepare(writer, str, len);
if (str == NULL)
return NULL;
- Py_MEMCPY(str, p, len);
+ memcpy(str, p, len);
PyMem_Free(p);
str += len;
return str;
@@ -626,7 +626,7 @@ _PyBytes_FormatEx(const char *format, Py_ssize_t format_len,
len = format_len - (fmt - format);
assert(len != 0);
- Py_MEMCPY(res, fmt, len);
+ memcpy(res, fmt, len);
res += len;
fmt += len;
fmtcnt -= (len - 1);
@@ -1009,7 +1009,7 @@ _PyBytes_FormatEx(const char *format, Py_ssize_t format_len,
}
/* Copy bytes */
- Py_MEMCPY(res, pbuf, len);
+ memcpy(res, pbuf, len);
res += len;
/* Pad right with the fill character if needed */
@@ -1473,12 +1473,12 @@ bytes_repeat(PyBytesObject *a, Py_ssize_t n)
}
i = 0;
if (i < size) {
- Py_MEMCPY(op->ob_sval, a->ob_sval, Py_SIZE(a));
+ memcpy(op->ob_sval, a->ob_sval, Py_SIZE(a));
i = Py_SIZE(a);
}
while (i < size) {
j = (i <= size-i) ? i : size-i;
- Py_MEMCPY(op->ob_sval+i, op->ob_sval, j);
+ memcpy(op->ob_sval+i, op->ob_sval, j);
i += j;
}
return (PyObject *) op;
@@ -2765,7 +2765,7 @@ bytes_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
n = PyBytes_GET_SIZE(tmp);
pnew = type->tp_alloc(type, n);
if (pnew != NULL) {
- Py_MEMCPY(PyBytes_AS_STRING(pnew),
+ memcpy(PyBytes_AS_STRING(pnew),
PyBytes_AS_STRING(tmp), n+1);
((PyBytesObject *)pnew)->ob_shash =
((PyBytesObject *)tmp)->ob_shash;
@@ -3237,7 +3237,7 @@ _PyBytesWriter_Resize(_PyBytesWriter *writer, void *str, Py_ssize_t size)
dest = PyByteArray_AS_STRING(writer->buffer);
else
dest = PyBytes_AS_STRING(writer->buffer);
- Py_MEMCPY(dest,
+ memcpy(dest,
writer->small_buffer,
pos);
}
@@ -3372,7 +3372,7 @@ _PyBytesWriter_WriteBytes(_PyBytesWriter *writer, void *ptr,
if (str == NULL)
return NULL;
- Py_MEMCPY(str, bytes, size);
+ memcpy(str, bytes, size);
str += size;
return str;
diff --git a/Objects/stringlib/join.h b/Objects/stringlib/join.h
index 90f966d..6f314e1 100644
--- a/Objects/stringlib/join.h
+++ b/Objects/stringlib/join.h
@@ -107,7 +107,7 @@ STRINGLIB(bytes_join)(PyObject *sep, PyObject *iterable)
for (i = 0; i < nbufs; i++) {
Py_ssize_t n = buffers[i].len;
char *q = buffers[i].buf;
- Py_MEMCPY(p, q, n);
+ memcpy(p, q, n);
p += n;
}
goto done;
@@ -116,12 +116,12 @@ STRINGLIB(bytes_join)(PyObject *sep, PyObject *iterable)
Py_ssize_t n;
char *q;
if (i) {
- Py_MEMCPY(p, sepstr, seplen);
+ memcpy(p, sepstr, seplen);
p += seplen;
}
n = buffers[i].len;
q = buffers[i].buf;
- Py_MEMCPY(p, q, n);
+ memcpy(p, q, n);
p += n;
}
goto done;
diff --git a/Objects/stringlib/transmogrify.h b/Objects/stringlib/transmogrify.h
index 9903912..a314572 100644
--- a/Objects/stringlib/transmogrify.h
+++ b/Objects/stringlib/transmogrify.h
@@ -108,7 +108,7 @@ pad(PyObject *self, Py_ssize_t left, Py_ssize_t right, char fill)
if (u) {
if (left)
memset(STRINGLIB_STR(u), fill, left);
- Py_MEMCPY(STRINGLIB_STR(u) + left,
+ memcpy(STRINGLIB_STR(u) + left,
STRINGLIB_STR(self),
STRINGLIB_LEN(self));
if (right)
@@ -275,13 +275,13 @@ stringlib_replace_interleave(PyObject *self,
if (to_len > 1) {
/* Lay the first one down (guaranteed this will occur) */
- Py_MEMCPY(result_s, to_s, to_len);
+ memcpy(result_s, to_s, to_len);
result_s += to_len;
count -= 1;
for (i = 0; i < count; i++) {
*result_s++ = *self_s++;
- Py_MEMCPY(result_s, to_s, to_len);
+ memcpy(result_s, to_s, to_len);
result_s += to_len;
}
}
@@ -297,7 +297,7 @@ stringlib_replace_interleave(PyObject *self,
}
/* Copy the rest of the original string */
- Py_MEMCPY(result_s, self_s, self_len - i);
+ memcpy(result_s, self_s, self_len - i);
return result;
}
@@ -337,11 +337,11 @@ stringlib_replace_delete_single_character(PyObject *self,
next = findchar(start, end - start, from_c);
if (next == NULL)
break;
- Py_MEMCPY(result_s, start, next - start);
+ memcpy(result_s, start, next - start);
result_s += (next - start);
start = next + 1;
}
- Py_MEMCPY(result_s, start, end - start);
+ memcpy(result_s, start, end - start);
return result;
}
@@ -390,12 +390,12 @@ stringlib_replace_delete_substring(PyObject *self,
break;
next = start + offset;
- Py_MEMCPY(result_s, start, next - start);
+ memcpy(result_s, start, next - start);
result_s += (next - start);
start = next + from_len;
}
- Py_MEMCPY(result_s, start, end - start);
+ memcpy(result_s, start, end - start);
return result;
}
@@ -427,7 +427,7 @@ stringlib_replace_single_character_in_place(PyObject *self,
return NULL;
}
result_s = STRINGLIB_STR(result);
- Py_MEMCPY(result_s, self_s, self_len);
+ memcpy(result_s, self_s, self_len);
/* change everything in-place, starting with this one */
start = result_s + (next - self_s);
@@ -477,11 +477,11 @@ stringlib_replace_substring_in_place(PyObject *self,
return NULL;
}
result_s = STRINGLIB_STR(result);
- Py_MEMCPY(result_s, self_s, self_len);
+ memcpy(result_s, self_s, self_len);
/* change everything in-place, starting with this one */
start = result_s + offset;
- Py_MEMCPY(start, to_s, from_len);
+ memcpy(start, to_s, from_len);
start += from_len;
end = result_s + self_len;
@@ -491,7 +491,7 @@ stringlib_replace_substring_in_place(PyObject *self,
0);
if (offset == -1)
break;
- Py_MEMCPY(start + offset, to_s, from_len);
+ memcpy(start + offset, to_s, from_len);
start += offset + from_len;
}
@@ -544,20 +544,20 @@ stringlib_replace_single_character(PyObject *self,
if (next == start) {
/* replace with the 'to' */
- Py_MEMCPY(result_s, to_s, to_len);
+ memcpy(result_s, to_s, to_len);
result_s += to_len;
start += 1;
} else {
/* copy the unchanged old then the 'to' */
- Py_MEMCPY(result_s, start, next - start);
+ memcpy(result_s, start, next - start);
result_s += (next - start);
- Py_MEMCPY(result_s, to_s, to_len);
+ memcpy(result_s, to_s, to_len);
result_s += to_len;
start = next + 1;
}
}
/* Copy the remainder of the remaining bytes */
- Py_MEMCPY(result_s, start, end - start);
+ memcpy(result_s, start, end - start);
return result;
}
@@ -613,20 +613,20 @@ stringlib_replace_substring(PyObject *self,
next = start + offset;
if (next == start) {
/* replace with the 'to' */
- Py_MEMCPY(result_s, to_s, to_len);
+ memcpy(result_s, to_s, to_len);
result_s += to_len;
start += from_len;
} else {
/* copy the unchanged old then the 'to' */
- Py_MEMCPY(result_s, start, next - start);
+ memcpy(result_s, start, next - start);
result_s += (next - start);
- Py_MEMCPY(result_s, to_s, to_len);
+ memcpy(result_s, to_s, to_len);
result_s += to_len;
start = next + from_len;
}
}
/* Copy the remainder of the remaining bytes */
- Py_MEMCPY(result_s, start, end - start);
+ memcpy(result_s, start, end - start);
return result;
}
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index aaebfd0..85cdbb7 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -1048,7 +1048,7 @@ resize_copy(PyObject *unicode, Py_ssize_t length)
return NULL;
copy_length = _PyUnicode_WSTR_LENGTH(unicode);
copy_length = Py_MIN(copy_length, length);
- Py_MEMCPY(_PyUnicode_WSTR(w), _PyUnicode_WSTR(unicode),
+ memcpy(_PyUnicode_WSTR(w), _PyUnicode_WSTR(unicode),
copy_length * sizeof(wchar_t));
return w;
}
@@ -1435,7 +1435,7 @@ _copy_characters(PyObject *to, Py_ssize_t to_start,
if (max_char >= 128)
return -1;
}
- Py_MEMCPY((char*)to_data + to_kind * to_start,
+ memcpy((char*)to_data + to_kind * to_start,
(char*)from_data + from_kind * from_start,
to_kind * how_many);
}
@@ -2024,7 +2024,7 @@ PyUnicode_FromUnicode(const Py_UNICODE *u, Py_ssize_t size)
break;
case PyUnicode_2BYTE_KIND:
#if Py_UNICODE_SIZE == 2
- Py_MEMCPY(PyUnicode_2BYTE_DATA(unicode), u, size * 2);
+ memcpy(PyUnicode_2BYTE_DATA(unicode), u, size * 2);
#else
_PyUnicode_CONVERT_BYTES(Py_UNICODE, Py_UCS2,
u, u + size, PyUnicode_2BYTE_DATA(unicode));
@@ -2037,7 +2037,7 @@ PyUnicode_FromUnicode(const Py_UNICODE *u, Py_ssize_t size)
unicode_convert_wchar_to_ucs4(u, u + size, unicode);
#else
assert(num_surrogates == 0);
- Py_MEMCPY(PyUnicode_4BYTE_DATA(unicode), u, size * 4);
+ memcpy(PyUnicode_4BYTE_DATA(unicode), u, size * 4);
#endif
break;
default:
@@ -2348,7 +2348,7 @@ _PyUnicode_Copy(PyObject *unicode)
return NULL;
assert(PyUnicode_KIND(copy) == PyUnicode_KIND(unicode));
- Py_MEMCPY(PyUnicode_DATA(copy), PyUnicode_DATA(unicode),
+ memcpy(PyUnicode_DATA(copy), PyUnicode_DATA(unicode),
length * PyUnicode_KIND(unicode));
assert(_PyUnicode_CheckConsistency(copy, 1));
return copy;
@@ -2454,7 +2454,7 @@ as_ucs4(PyObject *string, Py_UCS4 *target, Py_ssize_t targetsize,
}
else {
assert(kind == PyUnicode_4BYTE_KIND);
- Py_MEMCPY(target, data, len * sizeof(Py_UCS4));
+ memcpy(target, data, len * sizeof(Py_UCS4));
}
if (copy_null)
target[len] = 0;
@@ -2963,7 +2963,7 @@ unicode_aswidechar(PyObject *unicode,
size = res + 1;
else
res = size;
- Py_MEMCPY(w, wstr, size * sizeof(wchar_t));
+ memcpy(w, wstr, size * sizeof(wchar_t));
return res;
}
else
@@ -3986,7 +3986,7 @@ PyUnicode_AsUTF8AndSize(PyObject *unicode, Py_ssize_t *psize)
return NULL;
}
_PyUnicode_UTF8_LENGTH(unicode) = PyBytes_GET_SIZE(bytes);
- Py_MEMCPY(_PyUnicode_UTF8(unicode),
+ memcpy(_PyUnicode_UTF8(unicode),
PyBytes_AS_STRING(bytes),
_PyUnicode_UTF8_LENGTH(unicode) + 1);
Py_DECREF(bytes);
@@ -5473,7 +5473,7 @@ _PyUnicode_EncodeUTF32(PyObject *str,
}
if (PyBytes_Check(rep)) {
- Py_MEMCPY(out, PyBytes_AS_STRING(rep), repsize);
+ memcpy(out, PyBytes_AS_STRING(rep), repsize);
out += moreunits;
} else /* rep is unicode */ {
assert(PyUnicode_KIND(rep) == PyUnicode_1BYTE_KIND);
@@ -5825,7 +5825,7 @@ _PyUnicode_EncodeUTF16(PyObject *str,
}
if (PyBytes_Check(rep)) {
- Py_MEMCPY(out, PyBytes_AS_STRING(rep), repsize);
+ memcpy(out, PyBytes_AS_STRING(rep), repsize);
out += moreunits;
} else /* rep is unicode */ {
assert(PyUnicode_KIND(rep) == PyUnicode_1BYTE_KIND);
@@ -10012,7 +10012,7 @@ _PyUnicode_JoinArray(PyObject *separator, PyObject **items, Py_ssize_t seqlen)
/* Copy item, and maybe the separator. */
if (i && seplen != 0) {
- Py_MEMCPY(res_data,
+ memcpy(res_data,
sep_data,
kind * seplen);
res_data += kind * seplen;
@@ -10020,7 +10020,7 @@ _PyUnicode_JoinArray(PyObject *separator, PyObject **items, Py_ssize_t seqlen)
itemlen = PyUnicode_GET_LENGTH(item);
if (itemlen != 0) {
- Py_MEMCPY(res_data,
+ memcpy(res_data,
PyUnicode_DATA(item),
kind * itemlen);
res_data += kind * itemlen;
@@ -12396,11 +12396,11 @@ unicode_repeat(PyObject *str, Py_ssize_t len)
Py_ssize_t done = PyUnicode_GET_LENGTH(str);
const Py_ssize_t char_size = PyUnicode_KIND(str);
char *to = (char *) PyUnicode_DATA(u);
- Py_MEMCPY(to, PyUnicode_DATA(str),
+ memcpy(to, PyUnicode_DATA(str),
PyUnicode_GET_LENGTH(str) * char_size);
while (done < nchars) {
n = (done <= nchars-done) ? done : nchars-done;
- Py_MEMCPY(to + (done * char_size), to, n * char_size);
+ memcpy(to + (done * char_size), to, n * char_size);
done += n;
}
}
@@ -13531,7 +13531,7 @@ _PyUnicodeWriter_WriteASCIIString(_PyUnicodeWriter *writer,
const Py_UCS1 *str = (const Py_UCS1 *)ascii;
Py_UCS1 *data = writer->data;
- Py_MEMCPY(data + writer->pos, str, len);
+ memcpy(data + writer->pos, str, len);
break;
}
case PyUnicode_2BYTE_KIND:
@@ -14928,7 +14928,7 @@ unicode_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
_PyUnicode_WSTR(self) = (wchar_t *)data;
}
- Py_MEMCPY(data, PyUnicode_DATA(unicode),
+ memcpy(data, PyUnicode_DATA(unicode),
kind * (length + 1));
assert(_PyUnicode_CheckConsistency(self, 1));
#ifdef Py_DEBUG