diff options
author | Nicholas Clark <nick@ccl4.org> | 2007-09-19 22:52:53 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2007-09-19 22:52:53 +0000 |
commit | fda2d18a806c2883a36b25ff9f691418a05ccea0 (patch) | |
tree | a43f21aa60142c003cf36f24e18deb6ee3265d9f /hv.c | |
parent | 9dbc5603217e015b4c096a784947b1930341263c (diff) | |
download | perl-fda2d18a806c2883a36b25ff9f691418a05ccea0.tar.gz |
Inline and abolish S_hv_magic_uvar_xkey().
p4raw-id: //depot/perl@31917
Diffstat (limited to 'hv.c')
-rw-r--r-- | hv.c | 63 |
1 files changed, 29 insertions, 34 deletions
@@ -424,14 +424,29 @@ S_hv_fetch_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, return NULL; if (SvSMAGICAL(hv) && SvGMAGICAL(hv) && !(action & HV_DISABLE_UVAR_XKEY)) { - keysv = hv_magic_uvar_xkey(hv, keysv, key, klen, flags, action); - /* If a fetch-as-store fails on the fetch, then the action is to - recurse once into "hv_store". If we didn't do this, then that - recursive call would call the key conversion routine again. - However, as we replace the original key with the converted - key, this would result in a double conversion, which would show - up as a bug if the conversion routine is not idempotent. */ - hash = 0; + MAGIC* mg; + if ((mg = mg_find((SV*)hv, PERL_MAGIC_uvar))) { + struct ufuncs * const uf = (struct ufuncs *)mg->mg_ptr; + if (uf->uf_set == NULL) { + SV* obj = mg->mg_obj; + + if (!keysv) { + keysv = sv_2mortal(newSVpvn(key, klen)); + if (flags & HVhek_UTF8) + SvUTF8_on(keysv); + } + + mg->mg_obj = keysv; /* pass key */ + uf->uf_index = action; /* pass action */ + magic_getuvar((SV*)hv, mg); + keysv = mg->mg_obj; /* may have changed */ + mg->mg_obj = obj; + + /* If the key may have changed, then we need to invalidate + any passed-in computed hash value. */ + hash = 0; + } + } } if (keysv) { if (flags & HVhek_FREEKEY) @@ -789,6 +804,12 @@ S_hv_fetch_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, which in turn might do some tied magic. So we need to make that magic check happen. */ /* gonna assign to this, so it better be there */ + /* If a fetch-as-store fails on the fetch, then the action is to + recurse once into "hv_store". If we didn't do this, then that + recursive call would call the key conversion routine again. + However, as we replace the original key with the converted + key, this would result in a double conversion, which would show + up as a bug if the conversion routine is not idempotent. */ return hv_fetch_common(hv, keysv, key, klen, flags, HV_FETCH_ISSTORE|HV_DISABLE_UVAR_XKEY, val, hash); @@ -2524,32 +2545,6 @@ S_share_hek_flags(pTHX_ const char *str, I32 len, register U32 hash, int flags) return HeKEY_hek(entry); } -STATIC SV * -S_hv_magic_uvar_xkey(pTHX_ HV* hv, SV* keysv, const char *const key, - const STRLEN klen, const int k_flags, int action) -{ - MAGIC* mg; - if ((mg = mg_find((SV*)hv, PERL_MAGIC_uvar))) { - struct ufuncs * const uf = (struct ufuncs *)mg->mg_ptr; - if (uf->uf_set == NULL) { - SV* obj = mg->mg_obj; - - if (!keysv) { - keysv = sv_2mortal(newSVpvn(key, klen)); - if (k_flags & HVhek_UTF8) - SvUTF8_on(keysv); - } - - mg->mg_obj = keysv; /* pass key */ - uf->uf_index = action; /* pass action */ - magic_getuvar((SV*)hv, mg); - keysv = mg->mg_obj; /* may have changed */ - mg->mg_obj = obj; - } - } - return keysv; -} - I32 * Perl_hv_placeholders_p(pTHX_ HV *hv) { |