Subject: | url() shouldn't call query_string() unless needed |
Date: | Mon, 12 Aug 2013 13:27:52 +0200 |
To: | bug-CGI.pm [...] rt.cpan.org |
From: | "Frédéric Buclin" <lpsolit [...] gmail.com> |
Despite I call url() *without* query => 1, it calls query_string()
anyway which is quite slow when the URL contains several hundreds of
parameters (900 in my case): 70 ms per call! And I call this method
several times in a single CGI script so that's quite annoying as the
time penalty becomes very visible (0.3 second). The fix in url() is trivial:
--- CGI.pm 2013-08-12 13:18:56.388940276 +0200
+++ CGI.pm 2013-08-12 13:19:06.518713206 +0200
@@ -2817,7 +2817,7 @@ sub url {
my $path = $self->path_info;
my $script_name = $self->script_name;
my $request_uri = unescape($self->request_uri) || '';
- my $query_str = $self->query_string;
+ my $query_str = $query ? $self->query_string : '';
my $rewrite_in_use = $request_uri && $request_uri !~ /^\Q$script_name/;
Could you please include this fix for CGI 3.64? :)