Skip to content

perl5411delta.pod - add detail about IsCOW constant-folded strings #22723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion pod/perl5411delta.pod
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,21 @@ directly>. These cases are now fully supported.

=item *

Various optimizations related to handling of C<CONST>s.
Constant-folded strings are now sharable via the Copy-on-Write mechanism.
[L<GH #22163|https://github.com/Perl/perl5/pull/22163>]

The following code would previously have allocated eleven string buffers,
each containing one million "A"s:

C<my @scalars; push @scalars, ("A" x 1_000_000) for 0..9;>

Now a single buffer is allocated and shared between a CONST OP and
the ten scalar elements of L<@scalars>.

Note that any code using this sort of constant to simulate memory leaks
(perhaps in test files) must now permute the string in order to trigger
a string copy and the allocation of separate buffers. For example,
C<("A" x 1_000_000).time> might be a suitable small change.

=item *

Expand Down