From: Andy Lester Date: Tue, 2 May 2006 21:09:08 +0000 (-0500) Subject: optimize S_find_array_subscript X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4a021917c87977d18a33de03b9e43a13a14f24d7;p=p5sagit%2Fp5-mst-13.2.git optimize S_find_array_subscript Message-ID: <20060503020908.GA2234@petdance.com> p4raw-id: //depot/perl@28078 --- diff --git a/sv.c b/sv.c index 79b528b..dcc7a89 100644 --- a/sv.c +++ b/sv.c @@ -11753,16 +11753,17 @@ STATIC I32 S_find_array_subscript(pTHX_ AV *av, SV* val) { dVAR; - SV** svp; - I32 i; if (!av || SvMAGICAL(av) || !AvARRAY(av) || (AvFILLp(av) > FUV_MAX_SEARCH_SIZE)) return -1; - svp = AvARRAY(av); - for (i=AvFILLp(av); i>=0; i--) { - if (svp[i] == val && svp[i] != &PL_sv_undef) - return i; + if (val != &PL_sv_undef) { + SV ** const svp = AvARRAY(av); + I32 i; + + for (i=AvFILLp(av); i>=0; i--) + if (svp[i] == val) + return i; } return -1; }