From: Vincent Pit Date: Mon, 31 Jul 2017 15:45:52 +0000 (+0200) Subject: Revamp a_map_update_flags_topdown() X-Git-Tag: v0.17~4 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=fb8ae185db37d75973080191fc17ec24f44cd070;p=perl%2Fmodules%2Fautovivification.git Revamp a_map_update_flags_topdown() Make it take a mask so that it seems less magical. Also get rid of a_map_cancel(). --- diff --git a/autovivification.xs b/autovivification.xs index a744b79..554056c 100644 --- a/autovivification.xs +++ b/autovivification.xs @@ -238,17 +238,18 @@ static void a_map_store_root(pTHX_ const OP *root, OP *(*old_pp)(pTHX), UV flags return; } -static void a_map_update_flags_topdown(const OP *root, UV flags) { +static void a_map_update_flags_topdown(const OP *root, UV mask, UV flags) { a_op_info *oi; const OP *o = root; XSH_LOCK(&a_op_map_mutex); - flags &= ~A_HINT_ROOT; + mask |= A_HINT_ROOT; + flags &= ~mask; do { if ((oi = ptable_fetch(a_op_map, o))) - oi->flags = (oi->flags & (A_HINT_ROOT|A_HINT_SECOND)) | flags; + oi->flags = (oi->flags & mask) | flags; if (!(o->op_flags & OPf_KIDS)) break; o = a_map_descend(o); @@ -259,8 +260,6 @@ static void a_map_update_flags_topdown(const OP *root, UV flags) { return; } -#define a_map_cancel(R) a_map_update_flags_topdown((R), 0) - static void a_map_update_flags_bottomup(const OP *o, UV flags, UV rflags) { a_op_info *oi; @@ -1058,11 +1057,11 @@ static OP *a_ck_root(pTHX_ OP *o) { } } #endif - a_map_update_flags_topdown(o, hint | A_HINT_DEREF); + a_map_update_flags_topdown(o, A_HINT_SECOND, hint | A_HINT_DEREF); a_map_store_root(o, o->op_ppaddr, hint); o->op_ppaddr = new_pp; } else { - a_map_cancel(o); + a_map_update_flags_topdown(o, 0, 0); } } else a_map_delete(o);