Skip to content

Commit 0a0bd60

Browse files
committed
perl5411delta.pod - add detail about IsCOW constant-folded strings
1 parent a67a651 commit 0a0bd60

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

pod/perl5411delta.pod

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,21 @@ directly>. These cases are now fully supported.
2828

2929
=item *
3030

31-
Various optimizations related to handling of C<CONST>s.
31+
Constant-folded strings are now sharable via the Copy-on-Write mechanism.
32+
[L<GH #22163|https://github.com/Perl/perl5/pull/22163>]
33+
34+
The following code would previously have allocated eleven string buffers,
35+
each containing one million "A"s:
36+
37+
C<my @scalars; push @scalars, ("A" x 1_000_000) for 0..9;>
38+
39+
Now a single buffer is allocated and shared between a CONST OP and
40+
the ten scalar elements of L<@scalars>.
41+
42+
Note that any code using this sort of constant to simulate memory leaks
43+
(perhaps in test files) must now permute the string in order to trigger
44+
a string copy and the allocation of separate buffers. For example,
45+
C<("A" x 1_000_000).localtime> might be a suitable small change.
3246

3347
=item *
3448

0 commit comments

Comments
 (0)