From bddd34c507d5733ccd92c0f6dd8a6e6920fe42cd Mon Sep 17 00:00:00 2001 From: Richard Leach Date: Tue, 5 Nov 2024 00:35:44 +0000 Subject: [PATCH] perl5411delta.pod - add detail about IsCOW constant-folded strings --- pod/perl5411delta.pod | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pod/perl5411delta.pod b/pod/perl5411delta.pod index 73579737f6..4fd156c15b 100644 --- a/pod/perl5411delta.pod +++ b/pod/perl5411delta.pod @@ -28,7 +28,21 @@ directly>. These cases are now fully supported. =item * -Various optimizations related to handling of Cs. +Constant-folded strings are now sharable via the Copy-on-Write mechanism. +[L] + +The following code would previously have allocated eleven string buffers, +each containing one million "A"s: + +C + +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 *