httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject the effectiveness of split_to_parms
Date Fri, 19 Apr 2002 08:12:05 GMT

in request.c

Any reason why do we call unescape and req_plustospace functions in a 
loop, instead of doing this once on *data? I think calling the function 
once on a long string is faster then calling the same function 20 times 
(if we have 10 fields) on shorter strings.

Also what's the use of calling req_plustospace on the key string?

static void split_to_parms(apreq_request_t *req, const char *data)
{
     request_rec *r = req->r;
     const char *val;

     while (*data && (val = my_urlword(r->pool, &data))) {
	const char *key = ap_getword(r->pool, &val, '=');

	req_plustospace((char*)key);
	ap_unescape_url((char*)key);
	req_plustospace((char*)val);
	ap_unescape_url((char*)val);

	apr_table_add(req->parms, key, val);
     }

}

I'd write it as:

     req_plustospace((char*)data);
     ap_unescape_url((char*)data);
     while (*data && (val = my_urlword(r->pool, &data))) {
	apr_table_add(req->parms, ap_getword(r->pool, &val, '='), val);
     }

I'm not sure if it's valid to modify 'val' in the second arg and expect 
its value to be modified in the third. I must use a tmp var, right?

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com



Mime
View raw message