Subject: | Microoptimization: path_segments |
I think the attached patch might make URI::_generic::path_segments
faster in set mode (especially in void contexts) and has hopefully no
speed penalty in get mode.
Regards,
Slaven
Subject: | URI-pathcomponents.patch |
#
#
# To apply this patch:
# STEP 1: Chdir to the source directory.
# STEP 2: Run the 'applypatch' program with this patch file as input.
#
# If you do not have 'applypatch', it is part of the 'makepatch' package
# that you can fetch from the Comprehensive Perl Archive Network:
# http://www.perl.com/CPAN/authors/Johan_Vromans/makepatch-x.y.tar.gz
# In the above URL, 'x' should be 2 or higher.
#
# To apply this patch without the use of 'applypatch':
# STEP 1: Chdir to the source directory.
# STEP 2: Run the 'patch' program with this file as input.
#
#### End of Preamble ####
#### Patch data follows ####
diff -up 'URI-1.37-FCXd0N/URI/_generic.pm' 'new.URI-1.37/URI/_generic.pm'
Index: ./URI/_generic.pm
--- ./URI/_generic.pm Thu Apr 3 00:00:02 2008
+++ ./URI/_generic.pm Wed Oct 1 19:42:45 2008
@@ -89,7 +89,6 @@ sub _check_path
sub path_segments
{
my $self = shift;
- my $path = $self->path;
if (@_) {
my @arg = @_; # make a copy
for (@arg) {
@@ -106,6 +105,8 @@ sub path_segments
}
$self->path(join("/", @arg));
}
+ return if !defined wantarray;
+ my $path = $self->path;
return $path unless wantarray;
map {/;/ ? $self->_split_segment($_)
: uri_unescape($_) }
#### End of Patch data ####
#### ApplyPatch data follows ####
# Data version : 1.0
# Date generated : Wed Oct 1 19:46:41 2008
# Generated by : makepatch 2.00_12*
# Recurse directories : Yes
# Excluded files : (\A|/).*\~\Z
# (\A|/).*\.a\Z
# (\A|/).*\.bak\Z
# (\A|/).*\.BAK\Z
# (\A|/).*\.elc\Z
# (\A|/).*\.exe\Z
# (\A|/).*\.gz\Z
# (\A|/).*\.ln\Z
# (\A|/).*\.o\Z
# (\A|/).*\.obj\Z
# (\A|/).*\.olb\Z
# (\A|/).*\.old\Z
# (\A|/).*\.orig\Z
# (\A|/).*\.rej\Z
# (\A|/).*\.so\Z
# (\A|/).*\.Z\Z
# (\A|/)\.del\-.*\Z
# (\A|/)\.make\.state\Z
# (\A|/)\.nse_depinfo\Z
# (\A|/)core\Z
# (\A|/)tags\Z
# (\A|/)TAGS\Z
# p 'URI/_generic.pm' 5674 1222882965 0100644
#### End of ApplyPatch data ####
#### End of Patch kit [created: Wed Oct 1 19:46:41 2008] ####
#### Patch checksum: 55 1877 48834 ####
#### Checksum: 73 2501 34842 ####