summaryrefslogtreecommitdiff
path: root/hv.c
diff options
context:
space:
mode:
authorbulk88 (via RT) <perlbug-followup@perl.org>2012-12-23 18:20:10 -0800
committerDavid Mitchell <davem@iabyn.com>2013-01-29 11:16:44 +0000
commita03199eaa6f5d9e2d15c64750229e2adeebfbdce (patch)
tree44bc106e72c3d5852de650abf4733893a91203d1 /hv.c
parent113b1f2cec16524fab70408ae95f289ae8e096d3 (diff)
downloadperl-a03199eaa6f5d9e2d15c64750229e2adeebfbdce.tar.gz
hv.c: add some NULL check removal
The purpose is less machine instructions/faster code. * S_hv_free_ent_ret() is always called with entry non-null: so change its signature to reflect this, and remove a null check; * Add some SvREFCNT_dec_NNs; * In hv_clear(), refactor the code slightly to only do a SvREFCNT_dec_NN within the branch where its already been determined that the arg is non-null; also, use the _nocontext variant of Perl_croak() to save a push instruction in threaded perls.
Diffstat (limited to 'hv.c')
-rw-r--r--hv.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/hv.c b/hv.c
index 966a12f58e..5f7ae858f7 100644
--- a/hv.c
+++ b/hv.c
@@ -1377,7 +1377,7 @@ Perl_hv_copy_hints_hv(pTHX_ HV *const ohv)
else {
(void)hv_common(hv, heksv, HeKEY(entry), HeKLEN(entry),
HeKFLAGS(entry), HV_FETCH_ISSTORE|HV_FETCH_JUST_SV, sv, HeHASH(entry));
- SvREFCNT_dec(heksv);
+ SvREFCNT_dec_NN(heksv);
}
}
HvRITER_set(ohv, riter);
@@ -1399,8 +1399,6 @@ S_hv_free_ent_ret(pTHX_ HV *hv, HE *entry)
PERL_ARGS_ASSERT_HV_FREE_ENT_RET;
- if (!entry)
- return NULL;
val = HeVAL(entry);
if (HeKLEN(entry) == HEf_SVKEY) {
SvREFCNT_dec(HeKEY_sv(entry));
@@ -1481,14 +1479,15 @@ Perl_hv_clear(pTHX_ HV *hv)
for (; entry; entry = HeNEXT(entry)) {
/* not already placeholder */
if (HeVAL(entry) != &PL_sv_placeholder) {
- if (HeVAL(entry) && SvREADONLY(HeVAL(entry))
- && !SvIsCOW(HeVAL(entry))) {
- SV* const keysv = hv_iterkeysv(entry);
- Perl_croak(aTHX_
- "Attempt to delete readonly key '%"SVf"' from a restricted hash",
- (void*)keysv);
+ if (HeVAL(entry)) {
+ if (SvREADONLY(HeVAL(entry)) && !SvIsCOW(HeVAL(entry))) {
+ SV* const keysv = hv_iterkeysv(entry);
+ Perl_croak_nocontext(
+ "Attempt to delete readonly key '%"SVf"' from a restricted hash",
+ (void*)keysv);
+ }
+ SvREFCNT_dec_NN(HeVAL(entry));
}
- SvREFCNT_dec(HeVAL(entry));
HeVAL(entry) = &PL_sv_placeholder;
HvPLACEHOLDERS(hv)++;
}