summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2021-10-21 18:53:01 +0000
committerNicholas Clark <nicholas.clark@humanstate.com>2022-03-19 07:30:44 +0100
commit5983026606b07a11e381fbd9fca44a9e1fa7d497 (patch)
tree51e07e32a3380fb7edd8a5ae1ad1b03cdea7fff6
parent2c94601f0901d6917656208a57091e83be9bf07a (diff)
downloadperl-5983026606b07a11e381fbd9fca44a9e1fa7d497.tar.gz
Drop the unused hv argument from S_hv_free_ent_ret()
In turn, this means that the hv argument to Perl_hv_free_ent() and Perl_hv_delayfree_ent() is now clearly unused, so mark it as such. Both functions are deemed to be API, so unlike the static function S_hv_free_ent_ret we can't simply change their parameters. However, change all the internal callers to pass NULL instead of the hv, as this makes it obvious that the function does not read hv, and might cause the compiler to generate better code.
-rw-r--r--embed.fnc6
-rw-r--r--embed.h2
-rw-r--r--hv.c35
-rw-r--r--pp_sys.c4
-rw-r--r--proto.h14
5 files changed, 27 insertions, 34 deletions
diff --git a/embed.fnc b/embed.fnc
index 3706b3ebef..940135a0a5 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -1020,7 +1020,7 @@ po |struct xpvhv_aux*|hv_auxalloc|NN HV *hv
Apd |void |hv_clear |NULLOK HV *hv
: used in SAVEHINTS() and op.c
ApdR |HV * |hv_copy_hints_hv|NULLOK HV *const ohv
-Ap |void |hv_delayfree_ent|NN HV *hv|NULLOK HE *entry
+Ap |void |hv_delayfree_ent|NULLOK HV *notused|NULLOK HE *entry
AbMdp |SV* |hv_delete |NULLOK HV *hv|NN const char *key|I32 klen \
|I32 flags
AbMdp |SV* |hv_delete_ent |NULLOK HV *hv|NN SV *keysv|I32 flags|U32 hash
@@ -1036,7 +1036,7 @@ Cp |void* |hv_common_key_len|NULLOK HV *hv|NN const char *key \
|I32 klen_i32|const int action|NULLOK SV *val \
|const U32 hash
Apod |STRLEN |hv_fill |NN HV *const hv
-Ap |void |hv_free_ent |NN HV *hv|NULLOK HE *entry
+Ap |void |hv_free_ent |NULLOK HV *notused|NULLOK HE *entry
Apd |I32 |hv_iterinit |NN HV *hv
ApdR |char* |hv_iterkey |NN HE* entry|NN I32* retlen
ApdR |SV* |hv_iterkeysv |NN HE* entry
@@ -2898,7 +2898,7 @@ po |SV* |hfree_next_entry |NN HV *hv|NN STRLEN *indexp
#if defined(PERL_IN_HV_C)
S |void |hsplit |NN HV *hv|STRLEN const oldsize|STRLEN newsize
S |void |hv_free_entries|NN HV *hv
-S |SV* |hv_free_ent_ret|NN HV *hv|NN HE *entry
+S |SV* |hv_free_ent_ret|NN HE *entry
#if !defined(PURIFY)
SR |HE* |new_he
#endif
diff --git a/embed.h b/embed.h
index 8dbaaa94d7..f4b484f098 100644
--- a/embed.h
+++ b/embed.h
@@ -1710,7 +1710,7 @@
#define hsplit(a,b,c) S_hsplit(aTHX_ a,b,c)
#define hv_auxinit(a) S_hv_auxinit(aTHX_ a)
#define hv_delete_common(a,b,c,d,e,f,g) S_hv_delete_common(aTHX_ a,b,c,d,e,f,g)
-#define hv_free_ent_ret(a,b) S_hv_free_ent_ret(aTHX_ a,b)
+#define hv_free_ent_ret(a) S_hv_free_ent_ret(aTHX_ a)
#define hv_free_entries(a) S_hv_free_entries(aTHX_ a)
#define hv_magic_check S_hv_magic_check
#define hv_notallowed(a,b,c,d) S_hv_notallowed(aTHX_ a,b,c,d)
diff --git a/hv.c b/hv.c
index bc9af6da35..48d38230dd 100644
--- a/hv.c
+++ b/hv.c
@@ -1371,7 +1371,7 @@ S_hv_delete_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
if (SvOOK(hv) && HvLAZYDEL(hv) &&
entry == HeNEXT(HvAUX(hv)->xhv_eiter))
HeNEXT(HvAUX(hv)->xhv_eiter) = HeNEXT(entry);
- hv_free_ent(hv, entry);
+ hv_free_ent(NULL, entry);
}
xhv->xhv_keys--; /* HvTOTALKEYS(hv)-- */
if (xhv->xhv_keys == 0)
@@ -1809,15 +1809,11 @@ Perl_hv_copy_hints_hv(pTHX_ HV *const ohv)
/* like hv_free_ent, but returns the SV rather than freeing it */
STATIC SV*
-S_hv_free_ent_ret(pTHX_ HV *hv, HE *entry)
+S_hv_free_ent_ret(pTHX_ HE *entry)
{
- SV *val;
-
PERL_ARGS_ASSERT_HV_FREE_ENT_RET;
- PERL_UNUSED_ARG(hv);
-
- val = HeVAL(entry);
+ SV *val = HeVAL(entry);
if (HeKLEN(entry) == HEf_SVKEY) {
SvREFCNT_dec(HeKEY_sv(entry));
Safefree(HeKEY_hek(entry));
@@ -1834,23 +1830,22 @@ S_hv_free_ent_ret(pTHX_ HV *hv, HE *entry)
void
-Perl_hv_free_ent(pTHX_ HV *hv, HE *entry)
+Perl_hv_free_ent(pTHX_ HV *notused, HE *entry)
{
- SV *val;
-
- PERL_ARGS_ASSERT_HV_FREE_ENT;
+ PERL_UNUSED_ARG(notused);
if (!entry)
return;
- val = hv_free_ent_ret(hv, entry);
+
+ SV *val = hv_free_ent_ret(entry);
SvREFCNT_dec(val);
}
void
-Perl_hv_delayfree_ent(pTHX_ HV *hv, HE *entry)
+Perl_hv_delayfree_ent(pTHX_ HV *notused, HE *entry)
{
- PERL_ARGS_ASSERT_HV_DELAYFREE_ENT;
+ PERL_UNUSED_ARG(notused);
if (!entry)
return;
@@ -1859,7 +1854,7 @@ Perl_hv_delayfree_ent(pTHX_ HV *hv, HE *entry)
if (HeKLEN(entry) == HEf_SVKEY) {
sv_2mortal(SvREFCNT_inc(HeKEY_sv(entry)));
}
- hv_free_ent(hv, entry);
+ hv_free_ent(NULL, entry);
}
/*
@@ -1985,7 +1980,7 @@ S_clear_placeholders(pTHX_ HV *hv, const U32 placeholders)
if (SvOOK(hv) && HvLAZYDEL(hv) &&
entry == HeNEXT(HvAUX(hv)->xhv_eiter))
HeNEXT(HvAUX(hv)->xhv_eiter) = HeNEXT(entry);
- hv_free_ent(hv, entry);
+ hv_free_ent(NULL, entry);
}
if (--to_find == 0) {
@@ -2047,7 +2042,7 @@ Perl_hfree_next_entry(pTHX_ HV *hv, STRLEN *indexp)
* destructor call, so check each time */
if (entry && HvLAZYDEL(hv)) { /* was deleted earlier? */
HvLAZYDEL_off(hv);
- hv_free_ent(hv, entry);
+ hv_free_ent(NULL, entry);
/* warning: at this point HvARRAY may have been
* re-allocated, HvMAX changed etc */
}
@@ -2086,7 +2081,7 @@ Perl_hfree_next_entry(pTHX_ HV *hv, STRLEN *indexp)
);
}
}
- return hv_free_ent_ret(hv, entry);
+ return hv_free_ent_ret(entry);
}
@@ -2330,7 +2325,7 @@ Perl_hv_iterinit(pTHX_ HV *hv)
HE * const entry = iter->xhv_eiter; /* HvEITER(hv) */
if (entry && HvLAZYDEL(hv)) { /* was deleted earlier? */
HvLAZYDEL_off(hv);
- hv_free_ent(hv, entry);
+ hv_free_ent(NULL, entry);
}
iter->xhv_riter = -1; /* HvRITER(hv) = -1 */
iter->xhv_eiter = NULL; /* HvEITER(hv) = NULL */
@@ -2889,7 +2884,7 @@ Perl_hv_iternext_flags(pTHX_ HV *hv, I32 flags)
if (oldentry && HvLAZYDEL(hv)) { /* was deleted earlier? */
HvLAZYDEL_off(hv);
- hv_free_ent(hv, oldentry);
+ hv_free_ent(NULL, oldentry);
}
iter->xhv_eiter = entry; /* HvEITER(hv) = entry */
diff --git a/pp_sys.c b/pp_sys.c
index db266879bf..4cbe323ec5 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -874,7 +874,7 @@ PP(pp_tie)
methname = "TIEHASH";
if (HvLAZYDEL(varsv) && (entry = HvEITER_get((HV *)varsv))) {
HvLAZYDEL_off(varsv);
- hv_free_ent((HV *)varsv, entry);
+ hv_free_ent(NULL, entry);
}
HvEITER_set(MUTABLE_HV(varsv), 0);
HvRITER_set(MUTABLE_HV(varsv), -1);
@@ -1036,7 +1036,7 @@ PP(pp_untie)
HE *entry;
if (HvLAZYDEL(sv) && (entry = HvEITER_get((HV *)sv))) {
HvLAZYDEL_off(sv);
- hv_free_ent((HV *)sv, entry);
+ hv_free_ent(NULL, entry);
HvEITER_set(MUTABLE_HV(sv), 0);
}
}
diff --git a/proto.h b/proto.h
index 66fc248d3b..03830f8d7f 100644
--- a/proto.h
+++ b/proto.h
@@ -1441,9 +1441,8 @@ PERL_CALLCONV HV * Perl_hv_copy_hints_hv(pTHX_ HV *const ohv)
__attribute__warn_unused_result__;
#define PERL_ARGS_ASSERT_HV_COPY_HINTS_HV
-PERL_CALLCONV void Perl_hv_delayfree_ent(pTHX_ HV *hv, HE *entry);
-#define PERL_ARGS_ASSERT_HV_DELAYFREE_ENT \
- assert(hv)
+PERL_CALLCONV void Perl_hv_delayfree_ent(pTHX_ HV *notused, HE *entry);
+#define PERL_ARGS_ASSERT_HV_DELAYFREE_ENT
#ifndef NO_MATHOMS
PERL_CALLCONV SV* Perl_hv_delete(pTHX_ HV *hv, const char *key, I32 klen, I32 flags);
#define PERL_ARGS_ASSERT_HV_DELETE \
@@ -1495,9 +1494,8 @@ PERL_CALLCONV HE* Perl_hv_fetch_ent(pTHX_ HV *hv, SV *keysv, I32 lval, U32 hash)
PERL_CALLCONV STRLEN Perl_hv_fill(pTHX_ HV *const hv);
#define PERL_ARGS_ASSERT_HV_FILL \
assert(hv)
-PERL_CALLCONV void Perl_hv_free_ent(pTHX_ HV *hv, HE *entry);
-#define PERL_ARGS_ASSERT_HV_FREE_ENT \
- assert(hv)
+PERL_CALLCONV void Perl_hv_free_ent(pTHX_ HV *notused, HE *entry);
+#define PERL_ARGS_ASSERT_HV_FREE_ENT
PERL_CALLCONV I32 Perl_hv_iterinit(pTHX_ HV *hv);
#define PERL_ARGS_ASSERT_HV_ITERINIT \
assert(hv)
@@ -5174,9 +5172,9 @@ STATIC struct xpvhv_aux* S_hv_auxinit(pTHX_ HV *hv);
assert(hv)
STATIC SV* S_hv_delete_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, int k_flags, I32 d_flags, U32 hash);
#define PERL_ARGS_ASSERT_HV_DELETE_COMMON
-STATIC SV* S_hv_free_ent_ret(pTHX_ HV *hv, HE *entry);
+STATIC SV* S_hv_free_ent_ret(pTHX_ HE *entry);
#define PERL_ARGS_ASSERT_HV_FREE_ENT_RET \
- assert(hv); assert(entry)
+ assert(entry)
STATIC void S_hv_free_entries(pTHX_ HV *hv);
#define PERL_ARGS_ASSERT_HV_FREE_ENTRIES \
assert(hv)