emacs-devel
[Top][All Lists]
Advanced

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

Re: [Emacs-diffs] master ef75c3b: Optimize `file-equal-p' and `file-in-d


From: Stefan Monnier
Subject: Re: [Emacs-diffs] master ef75c3b: Optimize `file-equal-p' and `file-in-directory-p' in Tramp
Date: Wed, 11 Nov 2015 11:07:44 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

>>> +  (when (string-equal
>>> +    (file-remote-p (expand-file-name filename1))
>>> +    (file-remote-p (expand-file-name filename2)))
>> 
>> The above args to string-equal aren't always strings: why not use
>> `equal' instead?
>> (string-equal nil "nil") is non-nil, so I think the code will work
>> correctly but only because file-remote-p should hopefully never return
>> "nil".

> file-remote-p never returns "nil".

That's what I meant by "I think the code will work correctly but only
because ...".

> It returns either the remote prefix of a file name (a string), or nil.

Can you really prove that "the remote prefix of a file name" will never
be "nil"?  Remember: your proof can only assume that one of filename1 or
filename2 is a Tramp file name (the other can be anything at all,
possibly matching any weird file-name-handler).

I think rather than try to prove it, it's easier to use `equal' and move on.


        Stefan



reply via email to

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