Commit dbe3741
committed
Perl_vnewSVpvf - use the pattern length to size the new PV buffer
This function currently creates a new SVt_PV with a minimum string
length buffer via:
sv = newSV(1);
Simple measurements from compiling perl show that this is often sufficient.
When it isn't, the final buffer length is often close to strlen(pat).
Common cases that require a realloc() now will not with this commit. In
other cases, realloc()s will still be required, but the number will
likely be smaller by one.
Although min length & alloc behaviour can vary across platforms and
compilers, the following numbers are likely indicative:
|strlen(pat)|Inital SvLEN before|Initial SvLEN now|Final SvLEN|
|-----------|-------------------|-----------------|-----------|
|004|16|016|016|
|058|16|060|060|
|071|16|073|120|
|104|16|106|106|
|104|16|106|200|
|122|16|124|124|
|123|16|125|125|
|123|16|125|168|
|377|16|379|379|1 parent 7a1fd31 commit dbe3741
1 file changed
+4
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10009 | 10009 | | |
10010 | 10010 | | |
10011 | 10011 | | |
10012 | | - | |
| 10012 | + | |
| 10013 | + | |
| 10014 | + | |
10013 | 10015 | | |
10014 | | - | |
| 10016 | + | |
10015 | 10017 | | |
10016 | 10018 | | |
10017 | 10019 | | |
| |||
0 commit comments