I'm using a third party module that writes a bunch of variables to the
subprocess_env table to setup data for the request. It has us making
repeated class method calls like this (for our usage with Mason):
<% Blah::foo('bletch') %>

where foo is in the Blah package merely doing this:

sub foo {
    my($s) = @_;
    my($r) = Apache->request();
    return $r->subprocess_env('foo_' . $s);
}

I'm thinking of changing the behvior to 
<% $ENV{'foo_bletch'} %>
but foo_bletch isn't in the %ENV hash, so I'm looking at initializing
every request to do this:
$r->subprocess_env->do(
 sub { my($k,$v)=@_;
   $ENV{$k}=$v;
 1; 
 }
);
to eliminate repeated accesses of the subprocess_env table; one call
populates %ENV and that's it.

Now, I don't want to kick off a debate on the performance problems that
reading/writing to the environment incur; I didn't design this behavior
I just want to make the best of it since this is what the application
requires of us. I just need to optimize access to the environment by
turning the dozen or so calls per request to Blah::foo to just %ENV.  

Any ideas regarding the expense of mulitple $r->subprocess_env vs.
accessing %ENV?

--
Salon Internet                          http://www.salon.com/
  Manager, Software and Systems "Livin' La Vida Unix!"
Ian Kallen <[EMAIL PROTECTED]> / AIM: iankallen / Fax: (415) 354-3326

Reply via email to