In a message dated 04-21-98, David Noon said to All about Quicksort, Final
Version
Hi All,
[snip]
In the ascending routine:
DN> // If the subfile is short use Insertion sort
DN> if (r > l)
DN> {
DN> for (i = l + 1; i <= r; ++i)
DN> {
DN> Hold_it_here = array[i];
DN> for (j = i; j > l && array[j-1] > Hold_it_here; --j)
DN> array[j] = array[j-1];
DN> array[j] = Hold_it_here;
DN> }
DN> }
[snip]
In the descending routine:
DN> // If the subfile is short use Insertion sort
DN> if (r > l)
DN> {
DN> for (i = l + 1; i <= r; ++i)
DN> {
DN> Hold_it_here = array[i];
DN> for (j = i; j > l && array[j-1] < Hold_it_here; --j)
DN> array[j] = array[j-1];
DN> array[j] = Hold_it_here;
DN> }
DN> }
In the above, the if (r > l) comparisons are redundant. A good optimizer
will filter them out, but it would have been better had I deleted them as
part of removing the "safety mechanisms" prior to releasing the code.
[Sorry!]
So, just delete the surrounding if statements and their braces from the for
loops. It might save you a nanosecond here and there.
Regards
Dave
___
* MR/2 2.25 #353 * One man's Windows are another man's walls.
--- Maximus/2 3.01
---------------
* Origin: DoNoR/2,Woking UK (44-1483-717905) (2:440/4)
|