Fix t_dist_cppstyle Perl performance issue (#4085).

This commit is contained in:
Wilson Snyder 2023-09-16 09:22:12 -04:00
parent 10fbe74cef
commit 891cc0f9b6
2 changed files with 16 additions and 14 deletions

View File

@ -24,8 +24,9 @@ Verilator 5.015 devel
* Support 'let'.
* Optimize Verilator executable size by refactoring error reporting routines (#4446). [Anthony Donlon]
* Optimize Verilation runtime pointers and graphs (#4396) (#4397) (#4398). [Krzysztof Bieganski, Antmicro Ltd]
* Optimize preparations towards multithreading Verilation (#4463) (#4476) (#4477) (#4479). [Kamil Rakoczy, Antmicro Ltd]
* Optimize preparations towards multithreaded Verilation (#4291) (#4463) (#4476) (#4477) (#4479). [Kamil Rakoczy, Antmicro Ltd]
* Fix Windows filename format, etc (#3873) (#4421). [Anthony Donlon].
* Fix t_dist_cppstyle Perl performance issue (#4085). [Srinivasan Venkataramanan]
* Fix using type in parameterized classes without #() (#4281) (#4440). [Anthony Donlon]
* Fix false INFINITELOOP on forever..mailbox.get() (#4323). [Srinivasan Venkataramanan]
* Fix data type of condition operation on class objects (#4345) (#4352). [Ryszard Rozak, Antmicro Ltd]

View File

@ -63,18 +63,19 @@ sub checkPattern {
my $pattern = shift;
my $message = shift;
my $offset = 0;
my $buffer = $contents;
while ($buffer =~ s/.*?^($pattern)//sm) {
my $lineno = offset_to_lineno($contents, $offset + $-[-1]);
$offset += $+[1];
error("$filename:$lineno: $message");
my $lineno = 0;
my $buffer;
foreach my $line (split(/\n/, $contents . "\n\n")) {
++$lineno;
if ($line ne "") {
# Don't do whole file at once - see issue #4085
# Build a buffer until a newline so we check a block at a time.
$buffer .= $line . "\n";
next;
}
if ($buffer =~ s/.*?^($pattern)//sm) {
error("$filename:$lineno: $message");
}
$buffer = "";
}
}
sub offset_to_lineno {
my $contents = shift;
my $offset = shift;
my $count = (substr $contents, 0, $offset) =~ tr/\n//;
return $count + 1;
}