Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b8fb197

Browse files
committed
Issue #19513: Simplify list_repr()
1 parent 99b7b1c commit b8fb197

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

Objects/listobject.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -359,14 +359,8 @@ list_repr(PyListObject *v)
359359

360360
_PyUnicodeWriter_Init(&writer);
361361
writer.overallocate = 1;
362-
if (Py_SIZE(v) > 1) {
363-
/* "[" + "1" + ", 2" * (len - 1) + "]" */
364-
writer.min_length = 1 + 1 + (2 + 1) * (Py_SIZE(v) - 1) + 1;
365-
}
366-
else {
367-
/* "[1]" */
368-
writer.min_length = 3;
369-
}
362+
/* "[" + "1" + ", 2" * (len - 1) + "]" */
363+
writer.min_length = 1 + 1 + (2 + 1) * (Py_SIZE(v) - 1) + 1;
370364

371365
if (_PyUnicodeWriter_WriteChar(&writer, '[') < 0)
372366
goto error;

0 commit comments

Comments
 (0)