diff options
author | David Mitchell <davem@iabyn.com> | 2014-06-10 13:54:13 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2014-07-08 16:40:03 +0100 |
commit | 1ed44841e79d19d36361c250aecabc75154c999c (patch) | |
tree | fe39d432a2af6a50d6817d6747dd70fcfb3b21f4 /ext/arybase | |
parent | 26443f8e448912975ced96860e4f51a9e1fbbaca (diff) | |
download | perl-1ed44841e79d19d36361c250aecabc75154c999c.tar.gz |
wrap op_sibling field access in OP_SIBLING* macros
Remove (almost all) direct access to the op_sibling field of OP structs,
and use these three new macros instead:
OP_SIBLING(o);
OP_HAS_SIBLING(o);
OP_SIBLING_set(o, new_value);
OP_HAS_SIBLING is intended to be a slightly more efficient version of
OP_SIBLING when only boolean context is needed.
For now these three macros are just defined in the obvious way:
#define OP_SIBLING(o) (0 + (o)->op_sibling)
#define OP_HAS_SIBLING(o) (cBOOL((o)->op_sibling))
#define OP_SIBLING_set(o, sib) ((o)->op_sibling = (sib))
but abstracting them out will allow us shortly to make the last pointer in
an op_sibling chain point back to the parent rather than being null, with
a new flag indicating whether this is the last op.
Perl_ck_fun() still has a couple of direct uses of op_sibling, since it
takes the field's address, which is not covered by these macros.
Diffstat (limited to 'ext/arybase')
-rw-r--r-- | ext/arybase/arybase.pm | 2 | ||||
-rw-r--r-- | ext/arybase/arybase.xs | 16 |
2 files changed, 10 insertions, 8 deletions
diff --git a/ext/arybase/arybase.pm b/ext/arybase/arybase.pm index 3c090d66c2..67c71e7915 100644 --- a/ext/arybase/arybase.pm +++ b/ext/arybase/arybase.pm @@ -1,6 +1,6 @@ package arybase; -our $VERSION = "0.07"; +our $VERSION = "0.08"; require XSLoader; XSLoader::load(); # This returns true, which makes require happy. diff --git a/ext/arybase/arybase.xs b/ext/arybase/arybase.xs index f8f9ce2b39..48358b564a 100644 --- a/ext/arybase/arybase.xs +++ b/ext/arybase/arybase.xs @@ -176,7 +176,7 @@ STATIC OP *ab_ck_sassign(pTHX_ OP *o) { o = (*ab_old_ck_sassign)(aTHX_ o); if (o->op_type == OP_SASSIGN && FEATURE_ARYBASE_IS_ENABLED) { OP *right = cBINOPx(o)->op_first; - OP *left = right->op_sibling; + OP *left = OP_SIBLING(right); if (left) ab_process_assignment(left, right); } return o; @@ -186,8 +186,9 @@ STATIC OP *ab_ck_aassign(pTHX_ OP *o) { o = (*ab_old_ck_aassign)(aTHX_ o); if (o->op_type == OP_AASSIGN && FEATURE_ARYBASE_IS_ENABLED) { OP *right = cBINOPx(o)->op_first; - OP *left = cBINOPx(right->op_sibling)->op_first->op_sibling; - right = cBINOPx(right)->op_first->op_sibling; + OP *left = OP_SIBLING(right); + left = OP_SIBLING(cBINOPx(left)->op_first); + right = OP_SIBLING(cBINOPx(right)->op_first); ab_process_assignment(left, right); } return o; @@ -375,10 +376,11 @@ static OP *ab_ck_base(pTHX_ OP *o) ab_map_store(o, o->op_ppaddr, base); o->op_ppaddr = new_pp; /* Break the aelemfast optimisation */ - if (o->op_type == OP_AELEM && - cBINOPo->op_first->op_sibling->op_type == OP_CONST) { - cBINOPo->op_first->op_sibling - = newUNOP(OP_NULL,0,cBINOPo->op_first->op_sibling); + if (o->op_type == OP_AELEM) { + OP *const first = cBINOPo->op_first; + if ( OP_SIBLING(first)->op_type == OP_CONST) { + OP_SIBLING_set(first, newUNOP(OP_NULL,0,OP_SIBLING(first))); + } } } else ab_map_delete(o); |