Optimize _PyUnicode_FastCopyCharacters() when maxchar(from) > maxchar(to)
diff --git a/Python/formatter_unicode.c b/Python/formatter_unicode.c
index fdb587d..cd66670 100644
--- a/Python/formatter_unicode.c
+++ b/Python/formatter_unicode.c
@@ -786,8 +786,10 @@
goto done;
/* Then the source string. */
- _PyUnicode_FastCopyCharacters(writer->buffer, writer->pos,
- value, 0, len);
+ if (len) {
+ _PyUnicode_FastCopyCharacters(writer->buffer, writer->pos,
+ value, 0, len);
+ }
writer->pos += (len + rpad);
result = 0;