[PATCHv2 3/3] hvsupport: skip non-matching lines early

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

 



Most of the lines we look at are not going to match one of the
driver types contained in $groups_regex.

Move on to the next line if it does not contain any of them early.
This speeds up the script execution by 50%, since this simple regex
does not have any capture groups.
---
 docs/hvsupport.pl | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/docs/hvsupport.pl b/docs/hvsupport.pl
index fca83ca..2ead2cf 100755
--- a/docs/hvsupport.pl
+++ b/docs/hvsupport.pl
@@ -212,6 +212,9 @@ foreach my $src (@srcs) {
     my $impl;
     while (defined($line = <FILE>)) {
         if (!$ingrp) {
+            # skip non-matching lines early to save time
+            next if not $line =~ /$groups_regex/;
+
             if ($line =~ /^\s*(?:static\s+)?($groups_regex)\s+(\w+)\s*=\s*{/ ||
                 $line =~ /^\s*(?:static\s+)?($groups_regex)\s+NAME\(\w+\)\s*=\s*{/) {
                 $ingrp = $1;
-- 
2.7.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]