summaryrefslogtreecommitdiff
path: root/regen/op_private
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <leonerd@leonerd.org.uk>2022-12-10 15:45:10 +0000
committerPaul Evans <leonerd@leonerd.org.uk>2022-12-19 17:27:55 +0000
commitabf1aa2b099b9613c2e6901d3f61eb8da735d934 (patch)
treebf21b4d273643874ea55af93ce951dd6d46f84bb /regen/op_private
parente53949d80e5b3c49f5b33071e988970b50cf8f66 (diff)
downloadperl-abf1aa2b099b9613c2e6901d3f61eb8da735d934.tar.gz
Define OP_HELEMEXISTSOR, a handy LOGOP shortcut for HELEM existence tests
This op is constructed using an OP_HELEM as the op_first and any scalar expression as the op_other. It is roughly equivalent to the following perl code: exists $hv{$key} ? $hv{$key} : OTHER except that the HV and the KEY expression are evaluated only once, and only one hv_* function is invoked to both test and obtain the value. It is therefore smaller and more efficient. Likewise, adding the OPpHELEMEXISTSOR_DELETE flag turns it into the equivalent of exists $hv{$key} ? delete $hv{$key} : OTHER
Diffstat (limited to 'regen/op_private')
-rw-r--r--regen/op_private4
1 files changed, 4 insertions, 0 deletions
diff --git a/regen/op_private b/regen/op_private
index f4b0a44067..b074a95c50 100644
--- a/regen/op_private
+++ b/regen/op_private
@@ -872,6 +872,10 @@ addbits('argdefelem',
6 => qw(OPpARG_IF_FALSE IF_FALSE),
);
+addbits('helemexistsor',
+ 7 => qw(OPpHELEMEXISTSOR_DELETE DELETE),
+);
+
1;
# ex: set ts=8 sts=4 sw=4 et: