[bugzilla-gnome-org-extensions] trace parser: Use more efficient utils



commit d634bf074d655894aeea0cff6af9207db5408af2
Author: Krzesimir Nowak <qdlacz gmail com>
Date:   Thu Nov 13 21:14:56 2014 +0100

    trace parser: Use more efficient utils

 TraceParser/Extension.pm |   13 +++++++------
 TraceParser/lib/Trace.pm |    7 ++++---
 2 files changed, 11 insertions(+), 9 deletions(-)
---
diff --git a/TraceParser/Extension.pm b/TraceParser/Extension.pm
index 5b36c78..254e593 100644
--- a/TraceParser/Extension.pm
+++ b/TraceParser/Extension.pm
@@ -32,6 +32,7 @@ use Bugzilla::Util qw(detaint_natural);
 use Bugzilla::Extension::TraceParser::Trace;
 
 use List::Util;
+use List::MoreUtils qw(any part);
 use POSIX qw(ceil);
 use Scalar::Util qw(blessed);
 
@@ -72,15 +73,15 @@ sub _check_duplicate_trace {
     if (@identical or @similar) {
         $dbh->bz_rollback_transaction if $dbh->bz_in_transaction;
         my $product = $bug->product;
-        my @prod_traces  = grep { $_->bug->product eq $product }
-                                (@identical, @similar);
-        my @other_traces = grep { $_->bug->product ne $product }
-                                (@identical, @similar);
+        my @parted_traces = part { $_->bug->product ne $product }
+                                 (@identical, @similar);
+        my $prod_traces = $parted_traces[0];
+        my $other_traces = $parted_traces[1];
 
         my %vars = (
             comment    => $comment,
-            prod_bugs  => _traces_to_bugs(\ prod_traces),
-            other_bugs => _traces_to_bugs(\ other_traces),
+            prod_bugs  => _traces_to_bugs($prod_traces),
+            other_bugs => _traces_to_bugs($other_traces),
             product    => $product,
         );
         my $total_other_bugs = scalar(@{ $vars{other_bugs} });
diff --git a/TraceParser/lib/Trace.pm b/TraceParser/lib/Trace.pm
index 9d2e365..1239865 100644
--- a/TraceParser/lib/Trace.pm
+++ b/TraceParser/lib/Trace.pm
@@ -31,6 +31,7 @@ use Scalar::Util qw(blessed);
 use File::Basename qw(basename dirname);
 use Parse::StackTrace;
 use Digest::MD5 qw(md5_base64);
+use List::MoreUtils qw(any);
 
 ###############################
 ####    Initialization     ####
@@ -270,7 +271,7 @@ sub interesting_threads {
     # "signal" or "segv" in the name.
     my @threads;
     foreach my $t (@{ $st->threads }) {
-        if (grep { $_->function =~ POSSIBLE_CRASH_FUNCTION } @{ $t->frames }) {
+        if (any { $_->function =~ POSSIBLE_CRASH_FUNCTION } @{ $t->frames }) {
             push(@threads, $t);
         }
     }
@@ -283,7 +284,7 @@ sub interesting_threads {
         my $function = $t->frames->[0]->function;
         if (($function !~ WAIT_FUNCTION
              or $function =~ INTERESTING_WAIT_FUNCTION)
-            and !grep { $_ eq $function } IGNORE_FUNCTIONS)
+            and !any { $_ eq $function } IGNORE_FUNCTIONS)
         {
             push(@threads, $t);
         }
@@ -373,7 +374,7 @@ sub _relevant_functions {
             $function = ".$function" if $function;
             $function = "$file$function";
         }
-        if (!grep($_ eq $function, IGNORE_FUNCTIONS)) {
+        if (!any { $_ eq $function } IGNORE_FUNCTIONS) {
             $function =~ s/^IA__//;
             push(@relevant, $function);
         }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]