[Catalyst-commits] r6247 - in trunk/HTTP-Body/lib/HTTP: . Body
andyg at dev.catalyst.perl.org
andyg at dev.catalyst.perl.org
Sat Mar 31 05:39:54 GMT 2007
Author: andyg
Date: 2007-03-31 05:39:54 +0100 (Sat, 31 Mar 2007)
New Revision: 6247
Modified:
trunk/HTTP-Body/lib/HTTP/Body.pm
trunk/HTTP-Body/lib/HTTP/Body/UrlEncoded.pm
Log:
HTTP::Body, tried using APR::Request for urlencoded parsing, but Perl is faster. Replaced tr/// with s/// which is faster.
Modified: trunk/HTTP-Body/lib/HTTP/Body/UrlEncoded.pm
===================================================================
--- trunk/HTTP-Body/lib/HTTP/Body/UrlEncoded.pm 2007-03-30 16:28:24 UTC (rev 6246)
+++ trunk/HTTP-Body/lib/HTTP/Body/UrlEncoded.pm 2007-03-31 04:39:54 UTC (rev 6247)
@@ -8,11 +8,9 @@
our %hex_chr;
-BEGIN {
- for my $num ( 0 .. 255 ) {
- my $h = sprintf "%02X", $num;
- $hex_chr{ lc $h } = $hex_chr{ uc $h } = chr $num;
- }
+for my $num ( 0 .. 255 ) {
+ my $h = sprintf "%02X", $num;
+ $hex_chr{ lc $h } = $hex_chr{ uc $h } = chr $num;
}
=head1 NAME
@@ -40,7 +38,12 @@
return unless $self->length == $self->content_length;
- $self->{buffer} =~ tr/+/ /;
+ # I tested parsing this using APR::Request, but perl is faster
+ # Pure-Perl 2560/s
+ # APR::Request 2305/s
+
+ # Note: s/// appears faster than tr///
+ $self->{buffer} =~ s/\+/ /g;
for my $pair ( split( /[&;]/, $self->{buffer} ) ) {
@@ -61,10 +64,12 @@
=back
-=head1 AUTHOR
+=head1 AUTHORS
Christian Hansen, C<ch at ngmedia.com>
+Andy Grundman, C<andy at hybridized.org>
+
=head1 LICENSE
This library is free software . You can redistribute it and/or modify
Modified: trunk/HTTP-Body/lib/HTTP/Body.pm
===================================================================
--- trunk/HTTP-Body/lib/HTTP/Body.pm 2007-03-30 16:28:24 UTC (rev 6246)
+++ trunk/HTTP-Body/lib/HTTP/Body.pm 2007-03-31 04:39:54 UTC (rev 6247)
@@ -4,7 +4,7 @@
use Carp qw[ ];
-our $VERSION = 0.9;
+our $VERSION = 0.91;
our $TYPES = {
'application/octet-stream' => 'HTTP::Body::OctetStream',
More information about the Catalyst-commits
mailing list