Commit 3dc75b6
committed
toke.c - only try to shrink an SV buffer when conceivably possible
A few places within toke.c try to return unused string buffer space by
doing something like:
if (SvCUR(sv) + 5 < SvLEN(sv)) {
SvPV_shrink_to_cur(sv);
}
The rationale for the 5 is not commented upon. Maybe it's a random
thumb in the air, maybe it was 1 byte for the trailing null plus
a 4 byte pointer to account for allocation alignment?
Either way, on a platform with 8 byte pointers, that code could
try to shrink buffers when there's no realistic chance of doing
so. (The space between chunk sizes will be at least 1x PTRSIZE,
often 2x PTRSIZE at smaller sizes and then progressively more.)
For a reallocation that is at least has the potential to be
meaningful, the difference between CUR and LEN should be at least:
* 1 byte for a trailing null byte +
* 1 byte to enable the SV to be COWed +
* 1x PTRSIZE
This commit changes makes that so.1 parent 482fd30 commit 3dc75b6
1 file changed
+8
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4421 | 4421 | | |
4422 | 4422 | | |
4423 | 4423 | | |
4424 | | - | |
4425 | | - | |
| 4424 | + | |
| 4425 | + | |
| 4426 | + | |
4426 | 4427 | | |
4427 | 4428 | | |
4428 | 4429 | | |
| |||
9793 | 9794 | | |
9794 | 9795 | | |
9795 | 9796 | | |
9796 | | - | |
| 9797 | + | |
| 9798 | + | |
| 9799 | + | |
9797 | 9800 | | |
9798 | 9801 | | |
9799 | 9802 | | |
| |||
11348 | 11351 | | |
11349 | 11352 | | |
11350 | 11353 | | |
11351 | | - | |
| 11354 | + | |
11352 | 11355 | | |
11353 | 11356 | | |
11354 | 11357 | | |
| |||
11877 | 11880 | | |
11878 | 11881 | | |
11879 | 11882 | | |
11880 | | - | |
11881 | | - | |
| 11883 | + | |
11882 | 11884 | | |
11883 | 11885 | | |
11884 | 11886 | | |
| |||
0 commit comments