diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2016-02-05 16:06:53 -0500 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2016-02-07 08:23:46 -0500 |
commit | 84f05d5723e1566ac2e5ee7c4700a66efbbcd2ff (patch) | |
tree | c2cef26544c696e60d3f8a53a502f3996a811010 /pp_hot.c | |
parent | 4b5c941e759b9302cc3663703de38cb61f3554db (diff) | |
download | perl-84f05d5723e1566ac2e5ee7c4700a66efbbcd2ff.tar.gz |
Lexical scoping in case statement is tricky.
Coverity CID 135142: Structurally dead code (UNREACHABLE)
The case labels are just effectively goto labels, and therefore
any variable initialization will not happen. That is not the case
luckily here, the variables will be always overwritten as needed.
But better not to introduce false lexical scopes to avoid future
misery.
In the general case, the only way to have lexically tighter scopes is
to have dedicated blocks for each case, but that doesn't easily work here,
with all the tricky jumping.
We could switch() the second time on CxTYPE(), and have these variables
scoped on an inner block, but since this is hot hot hot code, better
not to mess with that, and just hoist the variables to an outer scope.
Any deeper refactoring should be done with profilers at hand.
Diffstat (limited to 'pp_hot.c')
-rw-r--r-- | pp_hot.c | 12 |
1 files changed, 5 insertions, 7 deletions
@@ -2630,6 +2630,11 @@ PP(pp_iter) SV **itersvp; SV *retsv; + SV *sv; + AV *av; + IV ix; + IV inc; + cx = CX_CUR(); itersvp = CxITERVAR(cx); assert(itersvp); @@ -2715,12 +2720,6 @@ PP(pp_iter) break; } - { - SV *sv; - AV *av; - IV ix; - IV inc; - case CXt_LOOP_LIST: /* for (1,2,3) */ assert(OPpITER_REVERSED == 2); /* so inc becomes -1 or 1 */ @@ -2785,7 +2784,6 @@ PP(pp_iter) *itersvp = sv; SvREFCNT_dec(oldsv); break; - } default: DIE(aTHX_ "panic: pp_iter, type=%u", CxTYPE(cx)); |