[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Git][lintian/lintian][master] Speed up files/source-missing check



Title: GitLab

Nilesh Patra pushed to branch master at lintian / lintian

Commits:

  • bc1d6990
    by Andrius Merkys at 2024-06-19T15:10:50+00:00
    Speed up files/source-missing check
    

1 changed file:

Changes:

  • lib/Lintian/Check/Files/SourceMissing.pm
    ... ... @@ -43,6 +43,7 @@ const my $EMPTY => q{};
    43 43
     const my $DOLLAR => q{$};
    
    44 44
     const my $DOT => q{.};
    
    45 45
     const my $DOUBLE_DOT => q{..};
    
    46
    +const my $ITEM_NOT_FOUND => -1;
    
    46 47
     
    
    47 48
     use Moo;
    
    48 49
     use namespace::clean;
    
    ... ... @@ -147,21 +148,21 @@ sub visit_patched_files {
    147 148
         }
    
    148 149
     
    
    149 150
         my @lines = split(/\n/, $item->bytes);
    
    150
    -    my %line_length;
    
    151 151
     
    
    152
    -    my $position = 1;
    
    152
    +    my $longest;
    
    153
    +    my $length = $ITEM_NOT_FOUND;
    
    154
    +    my $position = 0;
    
    153 155
         for my $line (@lines) {
    
    156
    +        $position++;
    
    154 157
     
    
    155
    -        $line_length{$position} = length $line;
    
    156
    -
    
    157
    -    } continue {
    
    158
    -        ++$position;
    
    158
    +        if( length $line > $length ) {
    
    159
    +            $longest = $position;
    
    160
    +            $length = length $line;
    
    161
    +        }
    
    159 162
         }
    
    160 163
     
    
    161
    -    my $longest = max_by { $line_length{$_} } keys %line_length;
    
    162
    -
    
    163 164
         return
    
    164
    -      if !defined $longest || $line_length{$longest} <= $VERY_LONG_LINE_LENGTH;
    
    165
    +      if !defined $longest || $length <= $VERY_LONG_LINE_LENGTH;
    
    165 166
     
    
    166 167
         if ($item->basename =~ m{\.js$}i) {
    
    167 168
     
    


  • Reply to: