Skip to content

Commit

Permalink
Fix t_dist_cppstyle Perl performance issue (verilator#4085).
Browse files Browse the repository at this point in the history
  • Loading branch information
wsnyder committed Sep 16, 2023
1 parent 10fbe74 commit 891cc0f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
3 changes: 2 additions & 1 deletion Changes
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
27 changes: 14 additions & 13 deletions test_regress/t/t_dist_cppstyle.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 891cc0f

Please sign in to comment.