emacs-devel
[Top][All Lists]
Advanced

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

Re: File name completion with non-ascii filenames


From: Eli Zaretskii
Subject: Re: File name completion with non-ascii filenames
Date: Sat, 12 Jan 2002 12:33:55 +0200

> From: Richard Stallman <address@hidden>
> Date: Wed, 26 Dec 2001 12:33:04 -0500
> 
> I pointed out there's a possibility that decoding will be slow--but we
> don't know how slow it will be.  Perhaps it won't be slow enough to
> matter.
> 
> I suggest trying it first, and seeing how much of a slowdown it causes
> for a large directory.

Okay, I modified dired.c as shown below, and then ran the following
Lisp code:

    (setq file-name-coding-system 'hebrew-iso-8bit)
    (let ((i 50)
          (completion-ignore-case t))
      (while (> i 0)
        (file-name-all-completions "c" "/foo/bar")
        (setq i (1- i))))

where "c" and "/foo/bar" were chosen to yield a large number of
completions (more than 1500 in my case).  I timed this with the old
and the new version of dired.c; the old version took 6 seconds, while
the new about 7.5.

Is this a significant slowdown?  (I don't think so.)  Is this a good
way to compare the two versions?  Is the change I made the right one?

*** src/dired.c~0       Wed Dec 19 19:12:04 2001
--- src/dired.c Sat Jan 12 12:09:10 2002
*************** Lisp_Object Qfile_attributes;
*** 119,124 ****
--- 119,125 ----
  Lisp_Object Qfile_attributes_lessp;
  
  static int scmp P_ ((unsigned char *, unsigned char *, int));
+ static int fncmp P_ ((unsigned char *, unsigned char *, int, Lisp_Object));
  
  
  Lisp_Object
*************** file_name_completion (file, dirname, all
*** 543,550 ****
            goto quit;
          if (! DIRENTRY_NONEMPTY (dp)
              || len < XSTRING (encoded_file)->size
!             || 0 <= scmp (dp->d_name, XSTRING (encoded_file)->data,
!                           XSTRING (encoded_file)->size))
            continue;
  
            if (file_name_completion_stat (encoded_dir, dp, &st) < 0)
--- 544,551 ----
            goto quit;
          if (! DIRENTRY_NONEMPTY (dp)
              || len < XSTRING (encoded_file)->size
!             || 0 <= fncmp (dp->d_name, XSTRING (encoded_file)->data,
!                            XSTRING (encoded_file)->size, file))
            continue;
  
            if (file_name_completion_stat (encoded_dir, dp, &st) < 0)
*************** scmp (s1, s2, len)
*** 767,772 ****
--- 768,816 ----
    if (l == 0)
      return -1;
    else
+     return len - l;
+ }
+ 
+ int simple_downcase = 0;
+ 
+ static int
+ fncmp (s1, s2, len, fn)
+      unsigned char *s1, *s2;
+      int len;
+      Lisp_Object fn;
+ {
+   register int l = len;
+ 
+   if (!completion_ignore_case)
+     {
+       while (l && *s1++ == *s2++)
+       l--;
+     }
+   else if (simple_downcase)
+     {
+       while (l && DOWNCASE (*s1++) == DOWNCASE (*s2++))
+       l--;
+     }
+   else
+     {
+       Lisp_Object tem, de, zero, llen;
+ 
+       zero = make_number (0);
+       llen = make_number (len);
+       de = DECODE_FILE (build_string (s1));
+       tem = Fcompare_strings (fn, zero, llen, de, zero, llen, Qt);
+ 
+       if (EQ (tem, Qt))
+       return -1;
+       else if (XINT (tem) < 0)
+       return - XINT (tem) - 1;
+       else
+       return XINT (tem) - 1;
+     }
+ 
+   if (l == 0)
+     return -1;
+   else
      return len - l;
  }
  



reply via email to

[Prev in Thread] Current Thread [Next in Thread]