Message288256
It was a little mind-numbing to check this code, but it looks correct.
Please fix two nits for better readability. For review purposes, it was nice to have changes stand-out, but for the final code I would like to combine the two comments and the two new_allocated assignments into a single comment and single assignment:
/* The growth pattern is: 0, 4, 8, 16, 25, 35, 46, 58, 72, 88, ...
Note: new_allocated won't overflow because the largest possible value
is PY_SSIZE_T_MAX * (9 / 8) + 6 which always fits in a size_t.
*/
new_allocated = (size_t)newsize + (newsize >> 3) + (newsize < 9 ? 3 : 6);
Secondly, please rename the "size" variable to something like "num_allocated_bytes". It is confusing to have "newsize" mean the number of elements actually used while having "size" mean the number of bytes actually allocated (including the overallocation). |
|
Date |
User |
Action |
Args |
2017-02-21 03:19:17 | rhettinger | set | recipients:
+ rhettinger, tim.peters, mark.dickinson, vstinner, r.david.murray, martin.panter, serhiy.storchaka, xiang.zhang |
2017-02-21 03:19:17 | rhettinger | set | messageid: <1487647157.04.0.147072585854.issue27660@psf.upfronthosting.co.za> |
2017-02-21 03:19:17 | rhettinger | link | issue27660 messages |
2017-02-21 03:19:16 | rhettinger | create | |
|