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

Re: I need my head examined (on ppf_DirTree)



Bjarke Hammersholt Roune wrote:

>That sounds a bit expensive, to OR each byte (char) of the string together,
>but it really is not. Consider what is needed to compare two identical
>filenames that has a length of 8: 8 compares, 9 checks for null and 9
>iterations of some kind. Some implementations might utilise assembly

Or less. It only has to compare the strings until they differ.

>Now, the question is wheter 4,5 calls to strcmp() is slower or faster than a
>hash calculation, 1 call to strcmp and 4,5 hash value compares. The answer I
>come to is that hashing is faster. So in a 256 node tree of our kind,
>hashing is faster on average.

I don't think the speed gain would be big enough to make up for the
additional effort (an more importantly, complexity). But you could simply
implement it and do some benchmarking.

>Also, I was thinking about the fact that there usually aren't that many
>directories. Perhaps it would be more effecient to store directories in
>another kind of structure than a tree?

For example?
Arrays and lists are clearly slower.
Hashes have very unpredictable performance, as it depends on how similar
the names are.

And other than that... ?


	Christian
--

Drive A: not responding...Formatting C: instead