This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Don’t use PMf_ONCE flag for split-to-array
authorFather Chrysostomos <sprout@cpan.org>
Tue, 4 Dec 2012 22:52:45 +0000 (14:52 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Thu, 6 Dec 2012 05:31:42 +0000 (21:31 -0800)
commitbcea25a760263ce058f5588c6ae62af6f09a211e
treeaa53a93f8e38eb6c1083e3e5e46de49b1752b8c0
parent19b29141f68d34f2b832ff2cddd54122e3ed3c28
Don’t use PMf_ONCE flag for split-to-array

Currently the PMf_ONCE flag has two purposes.  It is used to indicate
that m?? must match only once.  That’s what distinguishes m?? and m//
internally.  The other use indicates that @x = split... modifies the
array in place.

Whenever the split op is modified to point straight to the array, the
PMf_ONCE flag is set.  pp_split checks both whether there is an array
attached to the op (via a GV in the pad under threads, or a pointer
from the op to the GV under non-threaded builds) and whether the
flag is set.

This makes the flag redundant in the split case.

Removing its use here not only simplifies the code and removes redun-
dant bit-fiddling, but also makes this comment in toke.c, added by
ad639bfb6, come true:

/* This is the only point in the code that sets PMf_ONCE:  */

(That was actually harmless, as it doesn’t hurt to have a stash refer-
ring to pmops that don’t use the PMf_USED flag, and the PMf_ONCE flag
is set for split way after that code is run.  It is also unnecessary
for split, as that bookkeeping code in toke.c only applies to the m??
use of PMf_ONCE.)

This commit also removes a gimme != G_ARRAY check that thas been
redundant since a6d8037e26a.
op.c
pp.c