summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
Diffstat (limited to 'Objects')
-rw-r--r--Objects/memoryobject.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c
index 524521a..8c21ac1 100644
--- a/Objects/memoryobject.c
+++ b/Objects/memoryobject.c
@@ -632,7 +632,7 @@ memory_subscript(PyMemoryViewObject *self, PyObject *key)
static int
memory_ass_sub(PyMemoryViewObject *self, PyObject *key, PyObject *value)
{
- Py_ssize_t start, len, bytelen, i;
+ Py_ssize_t start, len, bytelen;
Py_buffer srcview;
Py_buffer *view = &(self->view);
char *srcbuf, *destbuf;
@@ -702,16 +702,8 @@ memory_ass_sub(PyMemoryViewObject *self, PyObject *key, PyObject *value)
if (destbuf + bytelen < srcbuf || srcbuf + bytelen < destbuf)
/* No overlapping */
memcpy(destbuf, srcbuf, bytelen);
- else if (destbuf < srcbuf) {
- /* Copy in ascending order */
- for (i = 0; i < bytelen; i++)
- destbuf[i] = srcbuf[i];
- }
- else {
- /* Copy in descencing order */
- for (i = bytelen - 1; i >= 0; i--)
- destbuf[i] = srcbuf[i];
- }
+ else
+ memmove(destbuf, srcbuf, bytelen);
PyBuffer_Release(&srcview);
return 0;