[EMAIL PROTECTED] wrote:

> dougm       01/12/17 19:40:02
> 
>   Modified:    xs/Apache/SubProcess Apache__SubProcess.h
>   Log:
>   avoid calling av_len() more than once.
>   switch from using av_len() to AvFILLp
>   add av_items variable to avoid (-1 + 2) when there is no av_argv
>   
>   Revision  Changes    Path
>   1.4       +9 -6      modperl-2.0/xs/Apache/SubProcess/Apache__SubProcess.h
>   
>   Index: Apache__SubProcess.h
>   ===================================================================
>   RCS file: /home/cvs/modperl-2.0/xs/Apache/SubProcess/Apache__SubProcess.h,v
>   retrieving revision 1.3
>   retrieving revision 1.4
>   diff -u -r1.3 -r1.4
>   --- Apache__SubProcess.h    2001/12/18 03:24:49     1.3
>   +++ Apache__SubProcess.h    2001/12/18 03:40:02     1.4
>   @@ -115,12 +115,15 @@
>            const char **argv;
>            int i;
>            AV *av_argv;
>   +        I32 len=-1, av_items=0;
>            request_rec *r = modperl_xs_sv2request_rec(aTHX_ ST(0), NULL, cv);
>            const char *command = (const char *)SvPV_nolen(ST(1));
>    
>            if (items == 3) {
>                if (SvROK(ST(2)) && SvTYPE(SvRV(ST(2))) == SVt_PVAV) {
>                    av_argv = (AV*)SvREFCNT_inc(SvRV(ST(2)));
>   +                len = AvFILLp(av_argv);
>   +                av_items = len+1;
>                }
>                else {
>                    Perl_croak(aTHX_ usage);
>   @@ -129,21 +132,21 @@
>            else {
>                av_argv = newAV();
>            }
>   -        
>   +
>            /* ap_os_create_privileged_process expects ARGV as char
>             * **argv, with terminating NULL and the program itself as a
>             * first item.
>             */
>   -        argv = apr_palloc(r->pool,
>   -                          (3 + av_len(av_argv)) * sizeof(char *));
>   +        argv = apr_palloc(r->pool, (av_items + 2) * sizeof(char *));
>            argv[0] = command;
>   -        for (i = 0; i <= av_len(av_argv); i++) {
>   +        for (i = 0; i <= len; i++) {
>                argv[i+1] = (const char *)SvPV_nolen(AvARRAY(av_argv)[i]);
>            }
>            argv[i+1] = NULL;
>    #if 0
>   -        for (i=0; i<=av_len(av_argv)+2; i++) {
>   -            Perl_warn(aTHX_ "arg: %d %s\n", i, argv[i]);
>   +        for (i=0; i<=len+2; i++) {
>   +            Perl_warn(aTHX_ "arg: %d %s\n",
>   +                      i, argv[i] ? argv[i] : "NULL");
>            }
>    #endif

talking about style nits, when initialization should be:

foo = 5;

and when

foo=5;

or it doesn't matter?

_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:[EMAIL PROTECTED]  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to