simplify GIMME_V
authorDavid Mitchell <davem@iabyn.com>
Sun, 4 Nov 2012 18:23:25 +0000 (18:23 +0000)
committerDavid Mitchell <davem@iabyn.com>
Sun, 4 Nov 2012 18:23:25 +0000 (18:23 +0000)
Since OPf_WANT_VOID == G_VOID etc, we can substantially simplify
the OP_GIMME macro (which is what implements GIMME_V).
This saves 588 bytes in the perl executable on my -O2 system.

op.h

diff --git a/op.h b/op.h
index 9182b4d..bf933e4 100644 (file)
--- a/op.h
+++ b/op.h
@@ -66,11 +66,9 @@ typedef PERL_BITFIELD16 Optype;
    then all the other bit-fields before/after it should change their
    types too to let VC pack them into the same 4 byte integer.*/
 
+/* for efficiency, requires OPf_WANT_VOID == G_VOID etc */
 #define OP_GIMME(op,dfl) \
-       (((op)->op_flags & OPf_WANT) == OPf_WANT_VOID   ? G_VOID   : \
-        ((op)->op_flags & OPf_WANT) == OPf_WANT_SCALAR ? G_SCALAR : \
-        ((op)->op_flags & OPf_WANT) == OPf_WANT_LIST   ? G_ARRAY   : \
-        dfl)
+       (((op)->op_flags & OPf_WANT) ? ((op)->op_flags & OPf_WANT) : dfl)
 
 #define OP_GIMME_REVERSE(flags)        ((flags) & G_WANT)