Skip to content

Commit 1d9bb17

Browse files
committed
Revert unrelated changes
1 parent b036e72 commit 1d9bb17

1 file changed

Lines changed: 5 additions & 18 deletions

File tree

‎Objects/bytesobject.c‎

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3831,23 +3831,13 @@ byteswriter_resize(PyBytesWriter *writer, Py_ssize_t new_size, int resize)
38313831
}
38323832

38333833
Py_ssize_t alloc = new_size;
3834-
3835-
if (writer->obj != NULL) {
3836-
if (resize && writer->overallocate) {
3837-
if (alloc <= (PY_SSIZE_T_MAX - alloc / OVERALLOCATE_FACTOR)) {
3838-
alloc += alloc / OVERALLOCATE_FACTOR;
3839-
}
3840-
}
3841-
3842-
if (new_size <= old_allocated + old_allocated / 8) {
3843-
/* Moderate upsize; overallocate similar to list_resize() */
3844-
alloc = new_size + (new_size >> 3);
3845-
}
3846-
else {
3847-
/* Major upsize; resize up to exact size */
3848-
alloc = new_size;
3834+
if (resize && writer->overallocate) {
3835+
if (alloc <= (PY_SSIZE_T_MAX - alloc / OVERALLOCATE_FACTOR)) {
3836+
alloc += alloc / OVERALLOCATE_FACTOR;
38493837
}
3838+
}
38503839

3840+
if (writer->obj != NULL) {
38513841
if (writer->use_bytearray) {
38523842
if (PyByteArray_Resize(writer->obj, alloc)) {
38533843
#ifdef Py_DEBUG
@@ -3870,9 +3860,6 @@ byteswriter_resize(PyBytesWriter *writer, Py_ssize_t new_size, int resize)
38703860
assert(writer->obj != NULL);
38713861
}
38723862
else {
3873-
// Do not overallocate when the first bytes/bytearray object is
3874-
// allocated
3875-
38763863
char *data;
38773864
if (writer->use_bytearray) {
38783865
writer->obj = PyByteArray_FromStringAndSize(NULL, alloc);

0 commit comments

Comments
 (0)