From abf1aa2b099b9613c2e6901d3f61eb8da735d934 Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Sat, 10 Dec 2022 15:45:10 +0000 Subject: 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 --- ext/Opcode/Opcode.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'ext') diff --git a/ext/Opcode/Opcode.pm b/ext/Opcode/Opcode.pm index 9f28f900bf..5b0092d1bb 100644 --- a/ext/Opcode/Opcode.pm +++ b/ext/Opcode/Opcode.pm @@ -1,4 +1,4 @@ -package Opcode 1.62; +package Opcode 1.63; use strict; @@ -332,6 +332,7 @@ invert_opset function. list lslice splice push pop shift unshift reverse cond_expr flip flop andassign orassign dorassign and or dor xor + helemexistsor warn die lineseq nextstate scope enter leave -- cgit v1.2.1