From c941fb51a763b50ea8ceb343cf253ac80c4ca160 Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Mon, 4 Jul 2005 10:41:28 +0000 Subject: [PATCH] Inlining del_HE is actually a space optimisation. It's therefore likely also to be a speed optimisation. :-) p4raw-id: //depot/perl@25066 --- embed.fnc | 1 - embed.h | 2 -- hv.c | 31 +++++++++++++++---------------- proto.h | 3 --- 4 files changed, 15 insertions(+), 22 deletions(-) diff --git a/embed.fnc b/embed.fnc index 4340984..5bcac57 100644 --- a/embed.fnc +++ b/embed.fnc @@ -999,7 +999,6 @@ s |void |require_errno |NN GV *gv s |void |hsplit |NN HV *hv s |void |hfreeentries |HV *hv sa |HE* |new_he -s |void |del_he |NN HE *p sa |HEK* |save_hek_flags |NN const char *str|I32 len|U32 hash|int flags s |void |hv_magic_check |NN HV *hv|NN bool *needs_copy|NN bool *needs_store s |void |unshare_hek_or_pvn|NULLOK const HEK* hek|NULLOK const char* str|I32 len|U32 hash diff --git a/embed.h b/embed.h index 0c1bb8b..f8800b4 100644 --- a/embed.h +++ b/embed.h @@ -1037,7 +1037,6 @@ #define hsplit S_hsplit #define hfreeentries S_hfreeentries #define new_he S_new_he -#define del_he S_del_he #define save_hek_flags S_save_hek_flags #define hv_magic_check S_hv_magic_check #define unshare_hek_or_pvn S_unshare_hek_or_pvn @@ -3014,7 +3013,6 @@ #define hsplit(a) S_hsplit(aTHX_ a) #define hfreeentries(a) S_hfreeentries(aTHX_ a) #define new_he() S_new_he(aTHX) -#define del_he(a) S_del_he(aTHX_ a) #define save_hek_flags(a,b,c,d) S_save_hek_flags(aTHX_ a,b,c,d) #define hv_magic_check(a,b,c) S_hv_magic_check(aTHX_ a,b,c) #define unshare_hek_or_pvn(a,b,c,d) S_unshare_hek_or_pvn(aTHX_ a,b,c,d) diff --git a/hv.c b/hv.c index 42c5522..99e034e 100644 --- a/hv.c +++ b/hv.c @@ -54,6 +54,13 @@ S_more_he(pTHX) HeNEXT(he) = 0; } +#ifdef PURIFY + +#define new_HE() (HE*)safemalloc(sizeof(HE)) +#define del_HE(p) safefree((char*)p) + +#else + STATIC HE* S_new_he(pTHX) { @@ -67,24 +74,16 @@ S_new_he(pTHX) return he; } -STATIC void -S_del_he(pTHX_ HE *p) -{ - LOCK_SV_MUTEX; - HeNEXT(p) = (HE*)PL_he_root; - PL_he_root = p; - UNLOCK_SV_MUTEX; -} - -#ifdef PURIFY - -#define new_HE() (HE*)safemalloc(sizeof(HE)) -#define del_HE(p) safefree((char*)p) +#define new_HE() new_he() +#define del_HE(p) \ + STMT_START { \ + LOCK_SV_MUTEX; \ + HeNEXT(p) = (HE*)PL_he_root; \ + PL_he_root = p; \ + UNLOCK_SV_MUTEX; \ + } STMT_END -#else -#define new_HE() new_he() -#define del_HE(p) del_he(p) #endif diff --git a/proto.h b/proto.h index fb8bc8a..caaaf97 100644 --- a/proto.h +++ b/proto.h @@ -1988,9 +1988,6 @@ STATIC HE* S_new_he(pTHX) __attribute__malloc__ __attribute__warn_unused_result__; -STATIC void S_del_he(pTHX_ HE *p) - __attribute__nonnull__(pTHX_1); - STATIC HEK* S_save_hek_flags(pTHX_ const char *str, I32 len, U32 hash, int flags) __attribute__malloc__ __attribute__warn_unused_result__ -- 2.7.4