Skip to content

Commit d71b3a5

Browse files
committed
use memset instead of a for-loop
1 parent 306b8f6 commit d71b3a5

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

Python/codecs.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -739,9 +739,7 @@ PyObject *PyCodec_ReplaceErrors(PyObject *exc)
739739
}
740740
assert(slen == 0 || PyUnicode_KIND(res) == PyUnicode_2BYTE_KIND);
741741
Py_UCS2 *outp = PyUnicode_2BYTE_DATA(res);
742-
for (Py_ssize_t i = 0; i < slen; ++i) {
743-
outp[i] = Py_UNICODE_REPLACEMENT_CHARACTER;
744-
}
742+
memset(outp, Py_UNICODE_REPLACEMENT_CHARACTER, sizeof(Py_UCS2) * slen);
745743
assert(_PyUnicode_CheckConsistency(res, 1));
746744
return Py_BuildValue("(Nn)", res, end);
747745
}

0 commit comments

Comments
 (0)