Skip to content

Commit

Permalink
perl5411delta.pod - add detail about IsCOW constant-folded strings
Browse files Browse the repository at this point in the history
  • Loading branch information
richardleach committed Nov 5, 2024
1 parent a67a651 commit 0a0bd60
Showing 1 changed file with 15 additions and 1 deletion.
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).localtime> might be a suitable small change.

=item *

Expand Down

0 comments on commit 0a0bd60

Please sign in to comment.