mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-30 01:43:23 +00:00
hvsupport: construct the group regex upfront
The %groups hash contains all the driver types (e.g. virHypervisorDriver or virSecretDriver). When searching for all the APIs that are implemented by a driver of that specific driver type, we keep iterating over the %groups hash on every line we look at, then matching against the driver type. This is inefficient because it prevents perl from caching the regex and it executes the regex once for every driver type, even though one regex matching excludes all the others, since all the driver types are different. Construct the regex containing all the driver types upfront to save about 6.4s (~98%) of the script execution time.
This commit is contained in:
parent
ad9e72f5fa
commit
6dc1f10347
@ -207,28 +207,27 @@ foreach my $src (@srcs) {
|
|||||||
open FILE, "<$src" or
|
open FILE, "<$src" or
|
||||||
die "cannot read $src: $!";
|
die "cannot read $src: $!";
|
||||||
|
|
||||||
|
my $groups_regex = join("|", keys %groups);
|
||||||
$ingrp = undef;
|
$ingrp = undef;
|
||||||
my $impl;
|
my $impl;
|
||||||
while (defined($line = <FILE>)) {
|
while (defined($line = <FILE>)) {
|
||||||
if (!$ingrp) {
|
if (!$ingrp) {
|
||||||
foreach my $grp (keys %groups) {
|
if ($line =~ /^\s*(?:static\s+)?($groups_regex)\s+(\w+)\s*=\s*{/ ||
|
||||||
if ($line =~ /^\s*(?:static\s+)?$grp\s+(\w+)\s*=\s*{/ ||
|
$line =~ /^\s*(?:static\s+)?($groups_regex)\s+NAME\(\w+\)\s*=\s*{/) {
|
||||||
$line =~ /^\s*(?:static\s+)?$grp\s+NAME\(\w+\)\s*=\s*{/) {
|
$ingrp = $1;
|
||||||
$ingrp = $grp;
|
$impl = $src;
|
||||||
$impl = $src;
|
|
||||||
|
|
||||||
if ($impl =~ m,.*/node_device_(\w+)\.c,) {
|
if ($impl =~ m,.*/node_device_(\w+)\.c,) {
|
||||||
$impl = $1;
|
$impl = $1;
|
||||||
} else {
|
} else {
|
||||||
$impl =~ s,.*/(\w+?)_((\w+)_)?(\w+)\.c,$1,;
|
$impl =~ s,.*/(\w+?)_((\w+)_)?(\w+)\.c,$1,;
|
||||||
}
|
|
||||||
|
|
||||||
if ($groups{$ingrp}->{drivers}->{$impl}) {
|
|
||||||
die "Group $ingrp already contains $impl";
|
|
||||||
}
|
|
||||||
|
|
||||||
$groups{$ingrp}->{drivers}->{$impl} = {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($groups{$ingrp}->{drivers}->{$impl}) {
|
||||||
|
die "Group $ingrp already contains $impl";
|
||||||
|
}
|
||||||
|
|
||||||
|
$groups{$ingrp}->{drivers}->{$impl} = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user