Skip to content

Commit 9c0e0cc

Browse files
committed
perldelta for optimized match count idiom [GH #24558]
1 parent e20b302 commit 9c0e0cc

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

pod/perldelta.pod

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,18 @@ There may well be none in a stable release.
9999

100100
=item *
101101

102+
Counting the number of matches within a string using the following common
103+
idiom is now more streamlined.
104+
105+
C<my $count =()= $str =~ /$pat/g;>
106+
107+
Instead of pushing all matches to the stack in mortal SVs just so that
108+
the list assignment can count them, C<pp_match> maintains an internal
109+
count during matching and pushes only that at the completion of matching.
110+
[GH #24558]
111+
112+
=item *
113+
102114
XXX
103115

104116
=back

0 commit comments

Comments
 (0)