diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2007-05-12 14:07:18 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2007-05-12 14:07:18 +0000 |
commit | 0014aca8c0c07569371fd1856b48fdbc13523b17 (patch) | |
tree | 781da83cb48cacf6cf46158bc02452a3e48dfda3 /usr.sbin | |
parent | 3ec43b7435890a398936b8625e184eb76c26c9ff (diff) |
somewhat sneaky: allow PkgSpecs to be objects, so that we can perform
optimizations on them. For now, we just do the subpattern split once.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PkgSpec.pm | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PkgSpec.pm b/usr.sbin/pkg_add/OpenBSD/PkgSpec.pm index 320725895f1..77bd0548350 100644 --- a/usr.sbin/pkg_add/OpenBSD/PkgSpec.pm +++ b/usr.sbin/pkg_add/OpenBSD/PkgSpec.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PkgSpec.pm,v 1.4 2007/05/12 13:36:54 espie Exp $ +# $OpenBSD: PkgSpec.pm,v 1.5 2007/05/12 14:07:17 espie Exp $ # # Copyright (c) 2003-2005 Marc Espie <espie@openbsd.org> # @@ -212,10 +212,10 @@ sub subpattern_match sub match_ref { - my ($pattern, $r) = @_; + my ($self, $r) = @_; my @l = (); - for my $subpattern (split /\|/, $pattern) { + for my $subpattern (ref($self) ? $self->{patterns} : split /\|/, $self) { push(@l, subpattern_match($subpattern, $r)); } return @l; @@ -223,8 +223,15 @@ sub match_ref sub match { - my ($pattern, @list) = @_; - return match_ref($pattern, \@list); + my ($self, @list) = @_; + return match_ref($self, \@list); +} + +sub new +{ + my ($class, $pattern) = @_; + my @l = split /\|/, $pattern; + bless { patterns => \@l }, $class; } 1; |