Skip to content

Conversation

@richardleach
Copy link
Contributor

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
4 16 16 16
58 16 60 60
71 16 73 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

  • This set of changes does not require a perldelta entry.

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|
@richardleach richardleach merged commit dbe3741 into Perl:blead Mar 13, 2025
33 checks passed
@richardleach richardleach deleted the vnewSVpvf_patsize branch March 13, 2025 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants