emacs-devel
[Top][All Lists]
Advanced

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

Re: empty-directory predicate, native implementation


From: Arthur Miller
Subject: Re: empty-directory predicate, native implementation
Date: Wed, 14 Oct 2020 03:52:42 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Michael Albinus <michael.albinus@gmx.de>
>> Cc: Arthur Miller <arthur.miller@live.com>,  emacs-devel@gnu.org
>> Date: Tue, 13 Oct 2020 20:44:18 +0200
>> 
>> > As a bonus, we will be able to return the file names we read, not just
>> > ignore them.
>> 
>> I agree with your proposal. However, I don't see why it is a bonus to
>> know which file names have read already, because they are taken in
>> random order.
>
> The order depends on the filesystem.  For example, MS-Windows
> filesystems always report in alphabetic order.
>
>> I fail to see how does it help, whether a file name is returned
>> under the first N matches, or not.
>
> Well, it is easy to disregard the names if they aren't needed.

Your idea was definitely much simpler to implement, rather trivial :-).
I just tested for myself, and it seems to work well.

The only thing I am not sure about is how to deal with 0 count; I
mean if user explicitly ask for 0 count; the case when count is not
NILP. I have chosen not to deal with it all, I check for zer set
explicit limit for count to be [1,COUNT]. I am not sure if that is best
thing to do; maybe just to return Qnil? I am probably doing something
else wrong, advice apprecaiated. 

I had some problems until I realized i used wrong number converter; I
used fixnum, seems like I need fixnat. I am still not sure if I am
correct but it seems to work now. 

I tested this compared to my old "native" predicate, on GNU/Linux only
and just to run naked predicate on a big number of dirs, and it seems to
be just very slight difference; ~0.002 vs ~0.004 definitely not dramatic
as entire decimal place.

I needed to "touch" 2 other files due to chagned signature of
directory_files: lisp.h and sysdep.c.

In attached .el file are two small tests (I run them with M-:).

Attachment: dired.c.patch
Description: dired.c.patch

Attachment: sysdep.c.patch
Description: sysdep.c.patch

Attachment: lisp.h.patch
Description: lisp.h.patch

Attachment: dired-mark-empty.el
Description: dired-mark-empty.el


reply via email to

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