[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: FYI: ConditionalSet.pm
From: |
Alexandre Duret-Lutz |
Subject: |
Re: FYI: ConditionalSet.pm |
Date: |
Fri, 15 Nov 2002 11:11:42 +0100 |
User-agent: |
Gnus/5.090008 (Oort Gnus v0.08) Emacs/20.7 (i386-debian-linux-gnu) |
>>> "Raja" == Raja R Harinath <address@hidden> writes:
Raja> Hi,
Raja> Here's some I missed the last time.
Great, thanks! I'm checking this in.
[...]
2002-11-15 Alexandre Duret-Lutz <address@hidden>
* lib/Automake/ConditionalSet.pm (_permutations_worker): Ignore TRUE
conditions.
(permutations): Treat empty permutations as TRUE.
(invert): Simplify.
Suggested by Raja R Harinath.
Index: lib/Automake/ConditionalSet.pm
===================================================================
RCS file: /cvs/automake/automake/lib/Automake/ConditionalSet.pm,v
retrieving revision 1.2
diff -u -r1.2 ConditionalSet.pm
--- lib/Automake/ConditionalSet.pm 14 Nov 2002 22:37:30 -0000 1.2
+++ lib/Automake/ConditionalSet.pm 15 Nov 2002 10:10:33 -0000
@@ -2,7 +2,7 @@
use Carp;
use strict;
-use Automake::Conditional;
+use Automake::Conditional qw/TRUE FALSE/;
=head1 NAME
@@ -247,23 +247,23 @@
return () unless @conds;
my $cond = shift @conds;
+
+ # Ignore "TRUE" conditions, since they add nothing to permutations.
+ return &_permutations_worker (@conds) if $cond eq "TRUE";
+
(my $neg = $cond) =~ s/TRUE$/FALSE/;
# Recurse.
-
- # Don't merge `FALSE' conditions, since this will just create
- # a false Conditional, and we'll drop them later in ConditionalSet.
- # (Dropping them now limits the combinatoric explosion.)
my @ret = ();
foreach my $c (&_permutations_worker (@conds))
{
push (@ret, $c->merge_conds ($cond));
- push (@ret, $c->merge_conds ($neg)) if $neg ne 'FALSE';
+ push (@ret, $c->merge_conds ($neg));
}
if (! @ret)
{
push (@ret, new Automake::Conditional $cond);
- push (@ret, new Automake::Conditional $neg) if $neg ne 'FALSE';
+ push (@ret, new Automake::Conditional $neg);
}
return @ret;
@@ -311,6 +311,9 @@
}
my @res = _permutations_worker (keys %atomic_conds);
+ # An empty permutation is TRUE, because we ignore TRUE conditions
+ # in the recursions.
+ @res = (TRUE) unless @res;
my $res = new Automake::ConditionalSet @res;
$self->{'permutations'} = $res;
@@ -343,24 +346,17 @@
# Generate permutations for all subconditions.
my @perm = $self->permutations->conds;
- # Remove redundant conditions.
- @perm = Automake::Conditional::reduce @perm;
# Now remove all conditions which imply one of the input conditions.
my @conds = $self->conds;
- my @notconds = ();
- foreach my $perm (@perm)
- {
- push @notconds, $perm
- if ! $perm->implies_any (@conds);
- }
-
+ my @notconds =
+ grep { ! $_->implies_any (@conds) } $self->permutations->conds;
my $res = new Automake::ConditionalSet @notconds;
# Cache result.
$self->{'invert'} = $res;
# It's tempting to also set $res->{'invert'} to $self, but that
- # isn't a bad idea as $self hasn't been normalized in any way.
+ # is a bad idea as $self hasn't been normalized in any way.
# (Different inputs can produce the same inverted set.)
return $res;
}
--
Alexandre Duret-Lutz