From: Nicholas Clark Date: Thu, 20 Sep 2007 12:13:16 +0000 (+0000) Subject: Convert hv_delete_ent(), hv_exists_ent(), hv_fetch_ent() and X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4c2df08ca7dcec8d9dadbf994c085e23d96957a3;p=p5sagit%2Fp5-mst-13.2.git Convert hv_delete_ent(), hv_exists_ent(), hv_fetch_ent() and hv_store_ent() to macros, and consign the function bodies to history. Er, mathoms.c p4raw-id: //depot/perl@31924 --- diff --git a/embed.fnc b/embed.fnc index 38a52d3..5af749f 100644 --- a/embed.fnc +++ b/embed.fnc @@ -299,11 +299,11 @@ Apd |void |hv_clear |NULLOK HV* tb poM |HV * |hv_copy_hints_hv|NN HV *const ohv Ap |void |hv_delayfree_ent|NN HV* hv|NULLOK HE* entry Apd |SV* |hv_delete |NULLOK HV* tb|NN const char* key|I32 klen|I32 flags -Apd |SV* |hv_delete_ent |NULLOK HV* tb|NN SV* key|I32 flags|U32 hash +Abmd |SV* |hv_delete_ent |NULLOK HV* tb|NN SV* key|I32 flags|U32 hash ApdR |bool |hv_exists |NULLOK HV* tb|NN const char* key|I32 klen -ApdR |bool |hv_exists_ent |NULLOK HV* tb|NN SV* key|U32 hash +AbmdR |bool |hv_exists_ent |NULLOK HV* tb|NN SV* key|U32 hash Apd |SV** |hv_fetch |NULLOK HV* tb|NN const char* key|I32 klen|I32 lval -Apd |HE* |hv_fetch_ent |NULLOK HV* tb|NN SV* key|I32 lval|U32 hash +Abmd |HE* |hv_fetch_ent |NULLOK HV* tb|NN SV* key|I32 lval|U32 hash Ap |HE* |hv_common |NULLOK HV* tb|NULLOK SV* keysv \ |NULLOK const char* key|STRLEN klen|int flags \ |int action|NULLOK SV* val|U32 hash @@ -327,7 +327,7 @@ XEdpoM |struct refcounted_he *|refcounted_he_new \ |NULLOK SV *const key|NULLOK SV *const value Apd |SV** |hv_store |NULLOK HV* tb|NULLOK const char* key|I32 klen|NULLOK SV* val \ |U32 hash -Apd |HE* |hv_store_ent |NULLOK HV* tb|NULLOK SV* key|NULLOK SV* val|U32 hash +Abmd |HE* |hv_store_ent |NULLOK HV* tb|NULLOK SV* key|NULLOK SV* val|U32 hash ApM |SV** |hv_store_flags |NULLOK HV* tb|NULLOK const char* key|I32 klen|NULLOK SV* val \ |U32 hash|int flags Apd |void |hv_undef |NULLOK HV* tb diff --git a/embed.h b/embed.h index 34c81ef..1c64fea 100644 --- a/embed.h +++ b/embed.h @@ -280,11 +280,8 @@ #define hv_clear Perl_hv_clear #define hv_delayfree_ent Perl_hv_delayfree_ent #define hv_delete Perl_hv_delete -#define hv_delete_ent Perl_hv_delete_ent #define hv_exists Perl_hv_exists -#define hv_exists_ent Perl_hv_exists_ent #define hv_fetch Perl_hv_fetch -#define hv_fetch_ent Perl_hv_fetch_ent #define hv_common Perl_hv_common #define hv_free_ent Perl_hv_free_ent #define hv_iterinit Perl_hv_iterinit @@ -295,7 +292,6 @@ #define hv_iterval Perl_hv_iterval #define hv_ksplit Perl_hv_ksplit #define hv_store Perl_hv_store -#define hv_store_ent Perl_hv_store_ent #define hv_store_flags Perl_hv_store_flags #define hv_undef Perl_hv_undef #define ibcmp Perl_ibcmp @@ -2565,11 +2561,8 @@ #endif #define hv_delayfree_ent(a,b) Perl_hv_delayfree_ent(aTHX_ a,b) #define hv_delete(a,b,c,d) Perl_hv_delete(aTHX_ a,b,c,d) -#define hv_delete_ent(a,b,c,d) Perl_hv_delete_ent(aTHX_ a,b,c,d) #define hv_exists(a,b,c) Perl_hv_exists(aTHX_ a,b,c) -#define hv_exists_ent(a,b,c) Perl_hv_exists_ent(aTHX_ a,b,c) #define hv_fetch(a,b,c,d) Perl_hv_fetch(aTHX_ a,b,c,d) -#define hv_fetch_ent(a,b,c,d) Perl_hv_fetch_ent(aTHX_ a,b,c,d) #define hv_common(a,b,c,d,e,f,g,h) Perl_hv_common(aTHX_ a,b,c,d,e,f,g,h) #define hv_free_ent(a,b) Perl_hv_free_ent(aTHX_ a,b) #define hv_iterinit(a) Perl_hv_iterinit(aTHX_ a) @@ -2586,7 +2579,6 @@ #if defined(PERL_CORE) || defined(PERL_EXT) #endif #define hv_store(a,b,c,d,e) Perl_hv_store(aTHX_ a,b,c,d,e) -#define hv_store_ent(a,b,c,d) Perl_hv_store_ent(aTHX_ a,b,c,d) #define hv_store_flags(a,b,c,d,e,f) Perl_hv_store_flags(aTHX_ a,b,c,d,e,f) #define hv_undef(a) Perl_hv_undef(aTHX_ a) #define ibcmp(a,b,c) Perl_ibcmp(aTHX_ a,b,c) diff --git a/hv.c b/hv.c index a8c4875..1b8f74c 100644 --- a/hv.c +++ b/hv.c @@ -258,7 +258,7 @@ Perl_hv_store(pTHX_ HV *hv, const char *key, I32 klen_i32, SV *val, U32 hash) return hek ? &HeVAL(hek) : NULL; } -/* XXX This looks like an ideal candidate to inline */ +/* Tricky to inlike this because it needs a temporary variable */ SV** Perl_hv_store_flags(pTHX_ HV *hv, const char *key, I32 klen, SV *val, register U32 hash, int flags) @@ -297,13 +297,6 @@ information on how to use this function on tied hashes. =cut */ -/* XXX This looks like an ideal candidate to inline */ -HE * -Perl_hv_store_ent(pTHX_ HV *hv, SV *keysv, SV *val, U32 hash) -{ - return hv_common(hv, keysv, NULL, 0, 0, HV_FETCH_ISSTORE, val, hash); -} - /* =for apidoc hv_exists @@ -374,14 +367,6 @@ computed. =cut */ -/* XXX This looks like an ideal candidate to inline */ -bool -Perl_hv_exists_ent(pTHX_ HV *hv, SV *keysv, U32 hash) -{ - return hv_common(hv, keysv, NULL, 0, 0, HV_FETCH_ISEXISTS, 0, hash) - ? TRUE : FALSE; -} - /* returns an HE * structure with the all fields set */ /* note that hent_val will be a mortal sv for MAGICAL hashes */ /* @@ -402,13 +387,6 @@ information on how to use this function on tied hashes. */ HE * -Perl_hv_fetch_ent(pTHX_ HV *hv, SV *keysv, I32 lval, register U32 hash) -{ - return hv_common(hv, keysv, NULL, 0, 0, - (lval ? HV_FETCH_LVALUE : 0), NULL, hash); -} - -HE * Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, int flags, int action, SV *val, register U32 hash) { @@ -974,14 +952,6 @@ precomputed hash value, or 0 to ask for it to be computed. =cut */ -/* XXX This looks like an ideal candidate to inline */ -SV * -Perl_hv_delete_ent(pTHX_ HV *hv, SV *keysv, I32 flags, U32 hash) -{ - return (SV *) hv_common(hv, keysv, NULL, 0, 0, flags | HV_DELETE, NULL, - hash); -} - STATIC SV * S_hv_delete_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, int k_flags, I32 d_flags, U32 hash) diff --git a/hv.h b/hv.h index bb4a3e0..f91443d 100644 --- a/hv.h +++ b/hv.h @@ -412,6 +412,19 @@ C. ->shared_he_he.he_valu.hent_refcount), \ hek) +#define hv_store_ent(zlonk, awk, touche, zgruppp) \ + hv_common((zlonk), (awk), NULL, 0, 0, HV_FETCH_ISSTORE, (touche), (zgruppp)) + +#define hv_exists_ent(zlonk, awk, zgruppp) \ + (hv_common((zlonk), (awk), NULL, 0, 0, HV_FETCH_ISEXISTS, 0, (zgruppp))\ + ? TRUE : FALSE) +#define hv_fetch_ent(zlonk, awk, touche, zgruppp) \ + hv_common((zlonk), (awk), NULL, 0, 0, ((touche) ? HV_FETCH_LVALUE : 0), \ + NULL, (zgruppp)) +#define hv_delete_ent(zlonk, awk, touche, zgruppp) \ + ((SV *) hv_common((zlonk), (awk), NULL, 0, 0, (touche) | HV_DELETE, \ + NULL, (zgruppp))) + /* This refcounted he structure is used for storing the hints used for lexical pragmas. Without threads, it's basically struct he + refcount. With threads, life gets more complex as the structure needs to be shared diff --git a/mathoms.c b/mathoms.c index a8a28e6..077bda6 100644 --- a/mathoms.c +++ b/mathoms.c @@ -1210,6 +1210,34 @@ Perl_pack_cat(pTHX_ SV *cat, const char *pat, const char *patend, register SV ** packlist(cat, pat, patend, beglist, endlist); } + +HE * +Perl_hv_store_ent(pTHX_ HV *hv, SV *keysv, SV *val, U32 hash) +{ + return hv_common(hv, keysv, NULL, 0, 0, HV_FETCH_ISSTORE, val, hash); +} + +bool +Perl_hv_exists_ent(pTHX_ HV *hv, SV *keysv, U32 hash) +{ + return hv_common(hv, keysv, NULL, 0, 0, HV_FETCH_ISEXISTS, 0, hash) + ? TRUE : FALSE; +} + +HE * +Perl_hv_fetch_ent(pTHX_ HV *hv, SV *keysv, I32 lval, U32 hash) +{ + return hv_common(hv, keysv, NULL, 0, 0, + (lval ? HV_FETCH_LVALUE : 0), NULL, hash); +} + +SV * +Perl_hv_delete_ent(pTHX_ HV *hv, SV *keysv, I32 flags, U32 hash) +{ + return (SV *) hv_common(hv, keysv, NULL, 0, 0, flags | HV_DELETE, NULL, + hash); +} + #endif /* NO_MATHOMS */ /* diff --git a/proto.h b/proto.h index 49f02b8..d5e1887 100644 --- a/proto.h +++ b/proto.h @@ -687,22 +687,22 @@ PERL_CALLCONV void Perl_hv_delayfree_ent(pTHX_ HV* hv, HE* entry) PERL_CALLCONV SV* Perl_hv_delete(pTHX_ HV* tb, const char* key, I32 klen, I32 flags) __attribute__nonnull__(pTHX_2); -PERL_CALLCONV SV* Perl_hv_delete_ent(pTHX_ HV* tb, SV* key, I32 flags, U32 hash) - __attribute__nonnull__(pTHX_2); +/* PERL_CALLCONV SV* Perl_hv_delete_ent(pTHX_ HV* tb, SV* key, I32 flags, U32 hash) + __attribute__nonnull__(pTHX_2); */ PERL_CALLCONV bool Perl_hv_exists(pTHX_ HV* tb, const char* key, I32 klen) __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_2); -PERL_CALLCONV bool Perl_hv_exists_ent(pTHX_ HV* tb, SV* key, U32 hash) +/* PERL_CALLCONV bool Perl_hv_exists_ent(pTHX_ HV* tb, SV* key, U32 hash) __attribute__warn_unused_result__ - __attribute__nonnull__(pTHX_2); + __attribute__nonnull__(pTHX_2); */ PERL_CALLCONV SV** Perl_hv_fetch(pTHX_ HV* tb, const char* key, I32 klen, I32 lval) __attribute__nonnull__(pTHX_2); -PERL_CALLCONV HE* Perl_hv_fetch_ent(pTHX_ HV* tb, SV* key, I32 lval, U32 hash) - __attribute__nonnull__(pTHX_2); +/* PERL_CALLCONV HE* Perl_hv_fetch_ent(pTHX_ HV* tb, SV* key, I32 lval, U32 hash) + __attribute__nonnull__(pTHX_2); */ PERL_CALLCONV HE* Perl_hv_common(pTHX_ HV* tb, SV* keysv, const char* key, STRLEN klen, int flags, int action, SV* val, U32 hash); PERL_CALLCONV void Perl_hv_free_ent(pTHX_ HV* hv, HE* entryK) @@ -750,7 +750,7 @@ PERL_CALLCONV SV * Perl_refcounted_he_fetch(pTHX_ const struct refcounted_he *ch PERL_CALLCONV void Perl_refcounted_he_free(pTHX_ struct refcounted_he *he); PERL_CALLCONV struct refcounted_he * Perl_refcounted_he_new(pTHX_ struct refcounted_he *const parent, SV *const key, SV *const value); PERL_CALLCONV SV** Perl_hv_store(pTHX_ HV* tb, const char* key, I32 klen, SV* val, U32 hash); -PERL_CALLCONV HE* Perl_hv_store_ent(pTHX_ HV* tb, SV* key, SV* val, U32 hash); +/* PERL_CALLCONV HE* Perl_hv_store_ent(pTHX_ HV* tb, SV* key, SV* val, U32 hash); */ PERL_CALLCONV SV** Perl_hv_store_flags(pTHX_ HV* tb, const char* key, I32 klen, SV* val, U32 hash, int flags); PERL_CALLCONV void Perl_hv_undef(pTHX_ HV* tb); PERL_CALLCONV I32 Perl_ibcmp(pTHX_ const char* a, const char* b, I32 len)