summaryrefslogtreecommitdiff
path: root/lib/File
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-10-29 11:47:25 -0700
committerFather Chrysostomos <sprout@cpan.org>2011-10-29 11:47:25 -0700
commitf9417615f454460d5d0620b8ddce9c56abed6ac2 (patch)
tree9002b64b208f9dbf953d0a329f06913d26f50c80 /lib/File
parentd2a88f5fa949c1e5ffb97513103acb4954634e2b (diff)
downloadperl-f9417615f454460d5d0620b8ddce9c56abed6ac2.tar.gz
DosGlob: Don’t parse an pattern that will not be used
This is the same change for efficiency’s sake that was applied to File::Glob in commit edfed4c3099a.
Diffstat (limited to 'lib/File')
-rw-r--r--lib/File/DosGlob.pm40
1 files changed, 21 insertions, 19 deletions
diff --git a/lib/File/DosGlob.pm b/lib/File/DosGlob.pm
index 4c4232c4f3..23504ad220 100644
--- a/lib/File/DosGlob.pm
+++ b/lib/File/DosGlob.pm
@@ -115,20 +115,25 @@ sub glob {
# glob without args defaults to $_
$pat = $_ unless defined $pat;
- # extract patterns
- if ($pat =~ /\s/) {
+ # assume global context if not provided one
+ $cxix = '_G_' unless defined $cxix;
+
+ # if we're just beginning, do it all first
+ if (!$entries{$cxix}) {
+ # extract patterns
+ if ($pat =~ /\s/) {
require Text::ParseWords;
@pat = Text::ParseWords::parse_line('\s+',0,$pat);
- }
- else {
+ }
+ else {
push @pat, $pat;
- }
+ }
- # Mike Mestnik: made to do abc{1,2,3} == abc1 abc2 abc3.
- # abc3 will be the original {3} (and drop the {}).
- # abc1 abc2 will be put in @appendpat.
- # This was just the esiest way, not nearly the best.
- REHASH: {
+ # Mike Mestnik: made to do abc{1,2,3} == abc1 abc2 abc3.
+ # abc3 will be the original {3} (and drop the {}).
+ # abc1 abc2 will be put in @appendpat.
+ # This was just the esiest way, not nearly the best.
+ REHASH: {
my @appendpat = ();
for (@pat) {
# There must be a "," I.E. abc{efg} is not what we want.
@@ -162,19 +167,16 @@ sub glob {
}
goto REHASH;
}
- }
- for ( @pat ) {
+ }
+ for ( @pat ) {
s/\\{/{/g;
s/\\}/}/g;
s/\\,/,/g;
- }
- #print join ("\n", @pat). "\n";
+ }
+ #print join ("\n", @pat). "\n";
- # assume global context if not provided one
- $cxix = '_G_' unless defined $cxix;
-
- # if we're just beginning, do it all first
- $entries{$cxix} ||= [doglob(1,@pat)];
+ $entries{$cxix} = [doglob(1,@pat)];
+ }
# chuck it all out, quick or slow
if (wantarray) {