bug-coreutils
[Top][All Lists]
Advanced

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

Suggestion for speeding up Sort (GNU CoreUtils 7.4)


From: N . Shamsundar
Subject: Suggestion for speeding up Sort (GNU CoreUtils 7.4)
Date: Sun, 24 May 2009 02:29:45 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

This is a suggestion to speed up Sort, rather than a bug report.

The addition of the code given below at the entry to function mergelines() of 
GNU Sort will exploit of the special relation between the arguments (HI - NHI = 
T - (NLO + NHI)) to replace the merge operation with a less expensive copy 
operation if it so happens that the last element of LO and the first element of 
HI are in order with respect to each other. Since the two subarrays are already 
sorted, the merging can be accomplished with a simple memory copy.

    if(compare (lo - nlo, hi - 1) <= 0){
                     /* Skip merge */
        if (t - lo) do *--t = *--lo; while  (--nlo);
        return;
        }

Sincerely,

N. Shamsundar
Assoc. Professor (Retd.)
University of Houston






reply via email to

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