On Fri, Oct 04, 2013 at 05:45:56PM +0400, Alexander S. wrote:
> 2013/10/4 Raphaël Proust <[email protected]>:
> If we want to retain this patch, I'd suggest reversing array after
> sorting, not multiplying by `sortorder' in comparison functions. This
> avoids code duplication.

I disagree - rather than adding a sort call and changing the program's
runtime complexity, can't we just reduce the amount of lines _and_
duplication like this:

@@ -89,9 +93,9 @@ entcmp(const void *va, const void *vb)
        const Entry *a = va, *b = vb;

-       if(tflag)
-               return sortorder * (b->mtime - a->mtime);
-       else
-               return sortorder * strcmp(a->name, b->name);
+       return sortorder * (tflag ? b->mtime - a->mtime : strcmp(a->name, 
b->name));
 }

 void


With line wrapping as appropriate.

Thanks,
Rob

Reply via email to