Skip to content

Commit

Permalink
Convert hv_delete_ent(), hv_exists_ent(), hv_fetch_ent() and
Browse files Browse the repository at this point in the history
hv_store_ent() to macros, and consign the function bodies to history.
Er, mathoms.c

p4raw-id: //depot/perl@31924
  • Loading branch information
nwc10 committed Sep 20, 2007
1 parent 6b4de90 commit 4c2df08
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 50 deletions.
8 changes: 4 additions & 4 deletions embed.fnc
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 0 additions & 8 deletions embed.h
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
32 changes: 1 addition & 31 deletions hv.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 */
/*
Expand All @@ -401,13 +386,6 @@ information on how to use this function on tied hashes.
=cut
*/

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)
Expand Down Expand Up @@ -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)
Expand Down
13 changes: 13 additions & 0 deletions hv.h
Expand Up @@ -412,6 +412,19 @@ C<SV*>.
->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
Expand Down
28 changes: 28 additions & 0 deletions mathoms.c
Expand Up @@ -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 */

/*
Expand Down
14 changes: 7 additions & 7 deletions proto.h
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4c2df08

Please sign in to comment.