From d2e8e66f096b4dae2305cd0ca8acef8705c77dff Mon Sep 17 00:00:00 2001 From: Guillaume Rousse Date: Tue, 16 Nov 2010 23:05:08 +0100 Subject: [PATCH] fix optimisation (bug #312832), and explain the code --- completions/helpers/perl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/completions/helpers/perl b/completions/helpers/perl index 3c3a56b0..b3522ac0 100755 --- a/completions/helpers/perl +++ b/completions/helpers/perl @@ -8,8 +8,16 @@ my %seen; sub print_modules_real { my ($base, $dir, $word) = @_; - # return immediately if the base doesn't match - return if $base && $base !~ /^\Q$word/; + # return immediatly if potential completion doesn't match current word + # a double comparaison is used to avoid dealing with string lengths + # (the shorter being the pattern to be used as the regexp) + # word 'Fi', base 'File' -> match 'File' against 'Fi' + # word 'File::Sp', base 'File' -> match 'File::Sp' againt 'File' + return if + $base && + $word && + $base !~ /^\Q$word/ && + $word !~ /^\Q$base/; chdir($dir) or return;