On 24.08.2011 00:17, Bruno Haible wrote:
> Hi Vladimir,
>
>>> hash.c in order to properly detect ELOOP, which must be done as part
>>> of an unlimited-depth link following algorithm.  (If we didn't have
>>> the GNU mantra of no arbitrary limits, then we could declare ELOOP at
>>> SYMLOOP_MAX instead.)
>>>
>> Brent's algorithm is universal, sets no arbitrary limit and requires no
>> hash and is implemented in few lines at a slight cost of going through
>> the cycle potentially up to 2 (or was it 3?) times.
>> http://en.wikipedia.org/wiki/Cycle_detection#Brent.27s_algorithm
> Interesting idea.
>
> But in file system related code like here, we consider a system call to be 
> very
> expensive (as it implies a context switch to the kernel and back). Whereas
> adding one entry to a hash table is rather quick on average. Therefore we
> try to minimize the number of system calls, even if it causes an increase in
> temporary memory use.
>
There is increase in number of calls only in the case of symlink loop
which isn't normal operation condition. Wehereas code simplicity and
memory usage benefits occur in normal conditions.
But your argumentation makes sense as well. In such cases it's mostly
maintainer's personal preference which matters.
> Bruno
>
>


-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko


Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to