]> git.donarmstrong.com Git - debbugs.git/commitdiff
add _mergedwith_array for speed when filtering
authorDon Armstrong <don@donarmstrong.com>
Fri, 8 Jun 2018 20:38:40 +0000 (13:38 -0700)
committerDon Armstrong <don@donarmstrong.com>
Fri, 8 Jun 2018 20:38:40 +0000 (13:38 -0700)
Debbugs/Bug.pm

index 256084eccdc26ef41b9416e72e8d02a22550987b..38ebbe7ee034a0f069b06246dc6031f99bb99c76 100644 (file)
@@ -369,11 +369,23 @@ sub is_merged {
     return $self->mergedwith->count > 0;
 }
 
+has _mergedwith_array =>
+    (is => 'ro',
+     isa => 'ArrayRef[Int]',
+     builder => '_build_mergedwith_array',
+     lazy => 1,
+    );
+
+sub _build_mergedwith_array {
+    my $self = shift;
+    return [sort {$a <=> $b}
+            $self->_split_if_defined('mergedwith')];
+}
+
 sub _build_mergedwith {
     my $self = shift;
     return $self->bug_collection->
-       limit(sort {$a <=> $b}
-             $self->_split_if_defined('mergedwith'));
+       limit(@{$self->_mergedwith_array//[]});
 }
 sub _build_pending {
     return $_[0]->status->{pending} // '';
@@ -578,7 +590,7 @@ sub filter {
        return 1 if $self->matches($param{exclude});
     }
     if (exists $param{repeat_merged} and not $param{repeat_merged}) {
-       my @merged = sort {$a<=>$b} $self->bug, map {$_->bug} $self->mergedwith->members;
+       my @merged = sort {$a<=>$b} $self->bug, @{$self->_mergedwith_array // []};
        return 1 if first {sub {defined $_}}
             @{$param{seen_merged}}{@merged};
        @{$param{seen_merged}}{@merged} = (1) x @merged;