Nilesh Patra pushed to branch master at lintian / lintian


Commits:
f8a4fec1 by Sylvestre Ledru at 2026-08-29T09:03:46+05:30
Cruft.pm: use index() for the license keyword pre-search

Interpolating \Q$_\E in the match recompiled a regex for every
keyword/file pair, and /x discarded the surrounding spaces in the
pattern, so it was a plain substring search already. index() does the
same thing without compiling anything.

Perf: NYTProf on llvm-toolchain-snapshot (amd64) attributed 52s of a
1581s run to these two searches.

- - - - -
8f92a193 by Sylvestre Ledru at 2026-08-29T09:03:46+05:30
Cruft.pm: trim whitespace with builtin::trim

The unanchored alternation ^\s+|\s+$ with /g scans the whole buffer;
builtin::trim only touches the ends. It is no longer experimental
since Perl 5.40, which is in both trixie and sid.

Perf: NYTProf on llvm-toolchain-snapshot (amd64) attributed 46s of a
1581s run to these two substitutions; a micro-benchmark puts
builtin::trim two orders of magnitude faster still.

- - - - -
95efbb8b by Sylvestre Ledru at 2026-08-29T09:03:46+05:30
Depend on liblist-someutils-xs-perl

List::SomeUtils loads its XS implementation for all its functions
(via Module::Implementation) when List::SomeUtils::XS is installed,
and falls back to pure Perl otherwise. Lintian calls its functions
(any, none, first_value, uniq, ...) in many checks; installing the
XS module speeds them all up without any code change.

Perf: NYTProf on llvm-toolchain-snapshot (amd64) measured 54s spent
in pure-Perl List::SomeUtils across a 1581s run.

- - - - -


2 changed files:

- debian/control
- lib/Lintian/Check/Cruft.pm


Changes:

=====================================
debian/control
=====================================
@@ -117,6 +117,7 @@ Depends:
  libjson-maybexs-perl,
  liblist-compare-perl,
  liblist-someutils-perl,
+ liblist-someutils-xs-perl,
  liblist-utilsby-perl,
  libmoo-perl,
  libmoox-aliases-perl,


=====================================
lib/Lintian/Check/Cruft.pm
=====================================
@@ -32,6 +32,7 @@ use v5.20;
 use warnings;
 use utf8;
 
+use builtin qw(trim);
 use Const::Fast;
 use List::SomeUtils qw(any none);
 
@@ -751,7 +752,7 @@ sub clean_text {
     $text =~ s{\s++}{ }gsm;
 
     # trim both ends
-    $text =~ s/^\s+|\s+$//g;
+    $text = trim($text);
 
     return $text;
 }
@@ -770,7 +771,7 @@ sub _strip_punct() {
     $text =~ s{\s++}{ }gsm;
 
     # trim both ends
-    $text =~ s/^\s+|\s+$//g;
+    $text = trim($text);
 
     return $text;
 }
@@ -781,10 +782,10 @@ sub check_for_single_bad_license {
     # do fast keyword search
     # could make more sense as 'return 1 unless all' but does not work
     return 0
-      if none { $lowercase =~ / \Q$_\E /msx } @{$license_data->{keywords}};
+      if none { index($lowercase, $_) >= 0 } @{$license_data->{keywords}};
 
     return 0
-      if none { $clean =~ / \Q$_\E /msx }@{$license_data->{sentences}};
+      if none { index($clean, $_) >= 0 } @{$license_data->{sentences}};
 
     my $regex = $license_data->{regex};
     return 0



View it on GitLab: 
https://salsa.debian.org/lintian/lintian/-/compare/d1067d7429ecd7d93ec01e6a61493cf55d124ef2...95efbb8b9fea34d6efa7928569641cccffe26de4

-- 
View it on GitLab: 
https://salsa.debian.org/lintian/lintian/-/compare/d1067d7429ecd7d93ec01e6a61493cf55d124ef2...95efbb8b9fea34d6efa7928569641cccffe26de4
You're receiving this email because of your account on salsa.debian.org. Manage 
all notifications: https://salsa.debian.org/-/profile/notifications | Help: 
https://salsa.debian.org/help


Reply via email to