summaryrefslogtreecommitdiff
path: root/hv.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2005-05-09 08:48:46 +0000
committerNicholas Clark <nick@ccl4.org>2005-05-09 08:48:46 +0000
commitc8cd64651f654f22b1bfc6e04141770a129de64d (patch)
tree678ae660a8ad2e804d09815a0071b62962adff15 /hv.c
parent672994ceae26eaea7b543577cbf4ae1bf28d2934 (diff)
downloadperl-c8cd64651f654f22b1bfc6e04141770a129de64d.tar.gz
Simplify S_hv_notallowed slightly by passing a prebuilt message
template. (Also slightly smaller object code) p4raw-id: //depot/perl@24423
Diffstat (limited to 'hv.c')
-rw-r--r--hv.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/hv.c b/hv.c
index 9ab43b858f..dc840d7390 100644
--- a/hv.c
+++ b/hv.c
@@ -161,7 +161,7 @@ static void
S_hv_notallowed(pTHX_ int flags, const char *key, I32 klen,
const char *msg)
{
- SV *sv = sv_newmortal(), *esv = sv_newmortal();
+ SV *sv = sv_newmortal();
if (!(flags & HVhek_FREEKEY)) {
sv_setpvn(sv, key, klen);
}
@@ -173,8 +173,7 @@ S_hv_notallowed(pTHX_ int flags, const char *key, I32 klen,
if (flags & HVhek_UTF8) {
SvUTF8_on(sv);
}
- Perl_sv_setpvf(aTHX_ esv, "Attempt to %s a restricted hash", msg);
- Perl_croak(aTHX_ SvPVX(esv), sv);
+ Perl_croak(aTHX_ msg, sv);
}
/* (klen == HEf_SVKEY) is special for MAGICAL hv entries, meaning key slot
@@ -717,8 +716,8 @@ S_hv_fetch_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
if (!entry && SvREADONLY(hv) && !(action & HV_FETCH_ISEXISTS)) {
S_hv_notallowed(aTHX_ flags, key, klen,
- "access disallowed key '%"SVf"' in"
- );
+ "Attempt to access disallowed key '%"SVf"' in"
+ " a restricted hash");
}
if (!(action & (HV_FETCH_LVALUE|HV_FETCH_ISSTORE))) {
/* Not doing some form of store, so return failure. */
@@ -999,8 +998,8 @@ S_hv_delete_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
}
else if (SvREADONLY(hv) && HeVAL(entry) && SvREADONLY(HeVAL(entry))) {
S_hv_notallowed(aTHX_ k_flags, key, klen,
- "delete readonly key '%"SVf"' from"
- );
+ "Attempt to delete readonly key '%"SVf"' from"
+ " a restricted hash");
}
if (k_flags & HVhek_FREEKEY)
Safefree(key);
@@ -1040,8 +1039,8 @@ S_hv_delete_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
}
if (SvREADONLY(hv)) {
S_hv_notallowed(aTHX_ k_flags, key, klen,
- "delete disallowed key '%"SVf"' from"
- );
+ "Attempt to delete disallowed key '%"SVf"' from"
+ " a restricted hash");
}
if (k_flags & HVhek_FREEKEY)