]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blobdiff - Magic.xs
'store' and 'delete' uvar magics don't need the uvar/clear hack
[perl/modules/Variable-Magic.git] / Magic.xs
index 7fee00e5773d0d1ffb29c8801d6ffb15ce9b4dd1..5dc98a6d3a9038579ade44e4eefa02856bf13bbb 100644 (file)
--- a/Magic.xs
+++ b/Magic.xs
@@ -1257,9 +1257,9 @@ STATIC I32 vmg_svt_val(pTHX_ IV action, SV *sv) {
  if (uf[1].uf_set)
   uf[1].uf_set(aTHX_ action, sv);
 
- action &= HV_FETCH_ISSTORE | HV_FETCH_ISEXISTS | HV_FETCH_LVALUE | HV_DELETE;
  for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) {
   const vmg_wizard *w;
+
   switch (mg->mg_type) {
    case PERL_MAGIC_ext:
     break;
@@ -1269,8 +1269,11 @@ STATIC I32 vmg_svt_val(pTHX_ IV action, SV *sv) {
    default:
     continue;
   }
+
   w = vmg_wizard_from_mg(mg);
-  if (!w) continue;
+  if (!w)
+   continue;
+
   switch (w->uvar) {
    case 0:
     continue;
@@ -1278,7 +1281,9 @@ STATIC I32 vmg_svt_val(pTHX_ IV action, SV *sv) {
     if (!newkey)
      newkey = key = umg->mg_obj = sv_mortalcopy(umg->mg_obj);
   }
-  switch (action) {
+
+  switch (action
+             & (HV_FETCH_ISSTORE|HV_FETCH_ISEXISTS|HV_FETCH_LVALUE|HV_DELETE)) {
    case 0:
     if (w->cb_fetch)
      vmg_cb_call2(w->cb_fetch, w->opinfo, sv, mg->mg_obj, key);
@@ -1300,7 +1305,7 @@ STATIC I32 vmg_svt_val(pTHX_ IV action, SV *sv) {
   }
  }
 
- if (SvRMAGICAL(sv) && !tied) {
+ if (SvRMAGICAL(sv) && !tied && !(action & (HV_FETCH_ISSTORE|HV_DELETE))) {
   /* Temporarily hide the RMAGICAL flag of the hash so it isn't wrongly
    * mistaken for a tied hash by the rest of hv_common. It will be reset by
    * the op_ppaddr of a new fake op injected between the current and the next