I know you csan do it like this, but it adds an extra function call to
the common case: right now we get by with just one function call except
when the primary sort doesn't match.

Another thing we could do is combine all the sort methods into one big
function with a loop and a case statement.

It certainly makes sense to do some benchmarks.

-Daniel


On Fri, Feb 08, 2002 at 08:03:11PM +0800, Charles Jie <[EMAIL PROTECTED]> wrote:
> 3. About qsort, (I don't know how mutt is coded with qsort , but I have
>    some experiences using qsort to do multiple-level sorting on files.),
>    my approach will focus on the fcmp() function(fed to qsort), which
>    you can have arbitrary levels of sorting like below:
> 
>    fcmp(e1, e2)
>    {
>        for (i = 0; i < levels; i++)
>        {
>          sort_method_function_pointer = sort_with[i];
>          cmp = (*sort_method_function_pointer)(e1, e2);
>          if (cmp) return cmp;
>       }
>       return 0;
>     }
> 
>     A logic like this avoids multiple uses of qsort or a special
>     mutt_qsort(). What it adds is just a for-loop and an array. It won't
>     probably have an impact on performance because most of comparison
>     will just stop at 1st or 2nd level.

-- 
Daniel E. Eisenbud
[EMAIL PROTECTED]

"We should go forth on the shortest walk perchance, in the spirit of
undying adventure, never to return,--prepared to send back our embalmed
hearts only as relics to our desolate kingdoms."
                                        --Henry David Thoreau, "Walking"

Reply via email to