]> ruderich.org/simon Gitweb - blhc/blhc.git/commitdiff
Call Term::ANSIColor::colorstrip() only when necessary.
authorSimon Ruderich <simon@ruderich.org>
Mon, 26 Mar 2012 00:34:47 +0000 (02:34 +0200)
committerSimon Ruderich <simon@ruderich.org>
Mon, 26 Mar 2012 00:34:47 +0000 (02:34 +0200)
Most build logs contain no colors at all and colorstrip() is quite slow.

bin/blhc

index 5443eef5a4226db9e3c64a315d602b0eb470131f..5d408c31e0c6a70aaa5360c9c9ae667785abd001 100755 (executable)
--- a/bin/blhc
+++ b/bin/blhc
@@ -452,15 +452,17 @@ while (my $line = <>) {
     # Ignore compiler warnings for now.
     next if $line =~ /$warning_regex/o;
 
     # Ignore compiler warnings for now.
     next if $line =~ /$warning_regex/o;
 
-    # Remove all ANSI color sequences which are sometimes used in non-verbose
-    # builds.
-    $line = Term::ANSIColor::colorstrip($line);
-    # Also strip '\0xf' (delete previous character), used by Elinks' build
-    # system.
-    $line =~ s/\x0f//g;
-    # And "ESC(B" which seems to be used on armhf and hurd (not sure what it
-    # does).
-    $line =~ s/\033\(B//g;
+    if ($line =~ /\033/) { # esc
+        # Remove all ANSI color sequences which are sometimes used in
+        # non-verbose builds.
+        $line = Term::ANSIColor::colorstrip($line);
+        # Also strip '\0xf' (delete previous character), used by Elinks' build
+        # system.
+        $line =~ s/\x0f//g;
+        # And "ESC(B" which seems to be used on armhf and hurd (not sure what
+        # it does).
+        $line =~ s/\033\(B//g;
+    }
 
     # Check if this line indicates a non verbose build.
     my $non_verbose = is_non_verbose_build($line);
 
     # Check if this line indicates a non verbose build.
     my $non_verbose = is_non_verbose_build($line);