aboutsummaryrefslogtreecommitdiffstats
path: root/src/dired.c
diff options
context:
space:
mode:
authorStefan Monnier2009-03-17 19:05:40 +0000
committerStefan Monnier2009-03-17 19:05:40 +0000
commit2cd298e2db4ef3cd64ee7553a21c4bd7f01f1cd4 (patch)
tree07655e5c0af95641abac2cbb15d62d1a6cac9a61 /src/dired.c
parente597afcb8ba631d19988f77c7f3d9cd46444b542 (diff)
downloademacs-2cd298e2db4ef3cd64ee7553a21c4bd7f01f1cd4.tar.gz
emacs-2cd298e2db4ef3cd64ee7553a21c4bd7f01f1cd4.zip
(file_name_completion): Check completion-ignored-extensions
only if the entry can't affect bestmatch anyway. Stop the search early, as Ftry_completion already does.
Diffstat (limited to 'src/dired.c')
-rw-r--r--src/dired.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/dired.c b/src/dired.c
index 0779fcd3c89..b6bc7067736 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -537,6 +537,18 @@ file_name_completion (file, dirname, all_flag, ver_flag, predicate)
537 if (!all_flag) 537 if (!all_flag)
538 { 538 {
539 int skip; 539 int skip;
540
541 /* If this entry matches the current bestmatch, the only
542 thing it can do is increase matchcount, so don't bother
543 investigating it any further. */
544 if (!completion_ignore_case
545 /* The return result depends on whether it's the sole match. */
546 && matchcount > 1
547 && !includeall /* This match may allow includeall to 0. */
548 && len >= bestmatchsize
549 && 0 > scmp (dp->d_name, SDATA (bestmatch), bestmatchsize))
550 continue;
551
540 if (directoryp) 552 if (directoryp)
541 { 553 {
542#ifndef TRIVIAL_DIRECTORY_ENTRY 554#ifndef TRIVIAL_DIRECTORY_ENTRY
@@ -705,8 +717,7 @@ file_name_completion (file, dirname, all_flag, ver_flag, predicate)
705 /* This tests that the current file is an exact match 717 /* This tests that the current file is an exact match
706 but BESTMATCH is not (it is too long). */ 718 but BESTMATCH is not (it is too long). */
707 if ((matchsize == SCHARS (name) 719 if ((matchsize == SCHARS (name)
708 && matchsize + !!directoryp 720 && matchsize + !!directoryp < SCHARS (bestmatch))
709 < SCHARS (bestmatch))
710 || 721 ||
711 /* If there is no exact match ignoring case, 722 /* If there is no exact match ignoring case,
712 prefer a match that does not change the case 723 prefer a match that does not change the case
@@ -734,6 +745,20 @@ file_name_completion (file, dirname, all_flag, ver_flag, predicate)
734 bestmatch = name; 745 bestmatch = name;
735 } 746 }
736 bestmatchsize = matchsize; 747 bestmatchsize = matchsize;
748
749 /* If the best completion so far is reduced to the string
750 we're trying to complete, then we already know there's no
751 other completion, so there's no point looking any further. */
752 if (matchsize <= SCHARS (file)
753 && !includeall /* A future match may allow includeall to 0. */
754 /* If completion-ignore-case is non-nil, don't
755 short-circuit because we want to find the best
756 possible match *including* case differences. */
757 && (!completion_ignore_case || matchsize == 0)
758 /* The return value depends on whether it's the sole match. */
759 && matchcount > 1)
760 break;
761
737 } 762 }
738 } 763 }
739 764