diff options
author | Nicholas Clark <nick@ccl4.org> | 2021-07-19 07:01:15 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2021-07-26 07:06:00 +0000 |
commit | 2517717a8902648de577d07f548caba6e3f2ecea (patch) | |
tree | a528ad0591656cffc80277f949205cf613d300c8 | |
parent | 89d6fa6c7f697a2a64a3ec2c06f9ad3a9bb1846e (diff) | |
download | perl-2517717a8902648de577d07f548caba6e3f2ecea.tar.gz |
The cases for SVt_PVAV and SVt_PVHV in pp_defined are unreachable.
Remove them, and hit to the C compiler that it's unlikely that someone used
`defined` on a subroutine.
These have been unreachable since `defined @array` and `defined %hash`
became syntax errors. Whilst the same PP code is used for // and //=,
expressions such as`@a // @b` put the left array (or hash) in scalar
context, meaning that it always returns a define value.
(Should we warn on these?)
-rw-r--r-- | pp_hot.c | 16 |
1 files changed, 3 insertions, 13 deletions
@@ -1368,24 +1368,14 @@ PP(pp_defined) } defined = FALSE; - switch (SvTYPE(sv)) { - case SVt_PVAV: - if (AvMAX(sv) >= 0 || SvGMAGICAL(sv) || (SvRMAGICAL(sv) && mg_find(sv, PERL_MAGIC_tied))) - defined = TRUE; - break; - case SVt_PVHV: - if (HvARRAY(sv) || SvGMAGICAL(sv) || (SvRMAGICAL(sv) && mg_find(sv, PERL_MAGIC_tied))) - defined = TRUE; - break; - case SVt_PVCV: + if (UNLIKELY(SvTYPE(sv) == SVt_PVCV)) { if (CvROOT(sv) || CvXSUB(sv)) defined = TRUE; - break; - default: + } + else { SvGETMAGIC(sv); if (SvOK(sv)) defined = TRUE; - break; } if (is_dor) { |