You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Doug MacEachern <do...@covalent.net> on 2001/11/11 02:21:59 UTC

ap_cgi_var_lookup()

i would like to avoid calling ap_add_{common,cgi}_vars() in mod_perl and
just tie Perl's %ENV to a lookup function.  i cooked up some generated
code based logic in Perl's ExtUtils::Constant module.  the generated code
will probably explain itself better than i can, but here is a comment from
the gen_vars.pl script:

#the jist of this generated code is that we:
#do not want to build a hash table of 30-something entries
#do not want to do 30-something strcmps

#so what we do is this:
#call strlen() only once
#switch on length, then switch on optimal offset (name[offset])
#and memcmp (as few times as possible) with given length
#see comment in best_index() for detail

i put a proof-of-concept here:
http://httpd.apache.org/~dougm/mod_cgi_vars.tar.gz

reason i'm posting here is because the code could be used in
ssl_var_lookup() and the code generator could be extended to
deal with ssl-specific variables.  ssl_var_lookup() is currently a big
hairball of strcmps.  and the "30-something" in the comment above, is
quite a bit more than that for ssl_var_lookup().




Re: ap_cgi_var_lookup()

Posted by "William A. Rowe, Jr." <wr...@covalent.net>.
++1 on concept - this has irked me for some time now.  mod_isapi, mod_includes
and a ton of other modules query a given variable, not the entire list... so
this idea makes much good sense :)  Didn't have the brainpower/bandwidth to 
absorb the actual patch this weekend, but I'm looking forward to checking it
out this week!


Bill

----- Original Message ----- 
From: "Doug MacEachern" <do...@covalent.net>
To: <de...@httpd.apache.org>
Sent: Saturday, November 10, 2001 7:21 PM
Subject: ap_cgi_var_lookup()


> i would like to avoid calling ap_add_{common,cgi}_vars() in mod_perl and
> just tie Perl's %ENV to a lookup function.  i cooked up some generated
> code based logic in Perl's ExtUtils::Constant module.  the generated code
> will probably explain itself better than i can, but here is a comment from
> the gen_vars.pl script:
> 
> #the jist of this generated code is that we:
> #do not want to build a hash table of 30-something entries
> #do not want to do 30-something strcmps
> 
> #so what we do is this:
> #call strlen() only once
> #switch on length, then switch on optimal offset (name[offset])
> #and memcmp (as few times as possible) with given length
> #see comment in best_index() for detail
> 
> i put a proof-of-concept here:
> http://httpd.apache.org/~dougm/mod_cgi_vars.tar.gz
> 
> reason i'm posting here is because the code could be used in
> ssl_var_lookup() and the code generator could be extended to
> deal with ssl-specific variables.  ssl_var_lookup() is currently a big
> hairball of strcmps.  and the "30-something" in the comment above, is
> quite a bit more than that for ssl_var_lookup().
> 
> 
> 
> 


Re: ap_cgi_var_lookup()

Posted by Bill Stoddard <bi...@wstoddard.com>.
+1 in concept. Not reviewed.

Bill

----- Original Message ----- 
From: "Doug MacEachern" <do...@covalent.net>
To: <de...@httpd.apache.org>
Sent: Saturday, November 10, 2001 8:21 PM
Subject: ap_cgi_var_lookup()


> i would like to avoid calling ap_add_{common,cgi}_vars() in mod_perl and
> just tie Perl's %ENV to a lookup function.  i cooked up some generated
> code based logic in Perl's ExtUtils::Constant module.  the generated code
> will probably explain itself better than i can, but here is a comment from
> the gen_vars.pl script:
> 
> #the jist of this generated code is that we:
> #do not want to build a hash table of 30-something entries
> #do not want to do 30-something strcmps
> 
> #so what we do is this:
> #call strlen() only once
> #switch on length, then switch on optimal offset (name[offset])
> #and memcmp (as few times as possible) with given length
> #see comment in best_index() for detail
> 
> i put a proof-of-concept here:
> http://httpd.apache.org/~dougm/mod_cgi_vars.tar.gz
> 
> reason i'm posting here is because the code could be used in
> ssl_var_lookup() and the code generator could be extended to
> deal with ssl-specific variables.  ssl_var_lookup() is currently a big
> hairball of strcmps.  and the "30-something" in the comment above, is
> quite a bit more than that for ssl_var_lookup().
> 
> 
> 


Re: ap_cgi_var_lookup()

Posted by sterling <st...@covalent.net>.
Sweet -

that ssl_var_lookup needs something exactly like this.  I say you do the
same for that.

sterling

On Sat, 10 Nov 2001, Doug MacEachern wrote:

> i would like to avoid calling ap_add_{common,cgi}_vars() in mod_perl and
> just tie Perl's %ENV to a lookup function.  i cooked up some generated
> code based logic in Perl's ExtUtils::Constant module.  the generated code
> will probably explain itself better than i can, but here is a comment from
> the gen_vars.pl script:
>
> #the jist of this generated code is that we:
> #do not want to build a hash table of 30-something entries
> #do not want to do 30-something strcmps
>
> #so what we do is this:
> #call strlen() only once
> #switch on length, then switch on optimal offset (name[offset])
> #and memcmp (as few times as possible) with given length
> #see comment in best_index() for detail
>
> i put a proof-of-concept here:
> http://httpd.apache.org/~dougm/mod_cgi_vars.tar.gz
>
> reason i'm posting here is because the code could be used in
> ssl_var_lookup() and the code generator could be extended to
> deal with ssl-specific variables.  ssl_var_lookup() is currently a big
> hairball of strcmps.  and the "30-something" in the comment above, is
> quite a bit more than that for ssl_var_lookup().
>
>
>
>