Louis-Philippe Véronneau pushed to branch master at lintian / lintian
Commits:
b4ca5070 by Timo Paulssen at 2024-11-02T19:14:40+00:00
Make File::Contents::LineLength::visit_patched_files a bit faster.
No need to decode utf8 for lines shorter than our current longest
(since the utf8 for a bit of text is always more bytes than it has
codepoints)
No need to check sql insert/update statements on every line, only
the longest ones. And only need to check if we're in an sql file
a single time up front.
- - - - -
1 changed file:
- lib/Lintian/Check/Files/Contents/LineLength.pm
Changes:
=====================================
lib/Lintian/Check/Files/Contents/LineLength.pm
=====================================
@@ -100,18 +100,23 @@ sub visit_patched_files {
my $longest;
my $length = $ITEM_NOT_FOUND;
my $position = 0;
+ my $is_sql = $item->basename =~ /sql/i;
while (my $line = <$fd>) {
$position++;
- # Skip SQL insert and select statements
- next if ($line =~ /^(INSERT|SELECT)\s/i
- and $item->basename =~ /sql/i);
+ # If the line can't be longer than our current longest,
+ # no need to decode.
+ next if( length $line < $length );
# count codepoints, if possible
$line = decode_utf8($line)
if valid_utf8($line);
if( length $line > $length ) {
+ # Skip SQL insert and select statements
+ next if ($is_sql
+ and $line =~ /^(INSERT|SELECT)\s/i);
+
$longest = $position;
$length = length $line;
}
View it on GitLab:
https://salsa.debian.org/lintian/lintian/-/commit/b4ca5070dde072b39f9a0ad3e33dea0bf9e1881e
--
View it on GitLab:
https://salsa.debian.org/lintian/lintian/-/commit/b4ca5070dde072b39f9a0ad3e33dea0bf9e1881e
You're receiving this email because of your account on salsa.debian.org.