public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lib/sort.c, 2.6.22 kernel
@ 2007-08-08 23:19 Subbaiah Venkata
  2007-09-25 14:52 ` Jan Engelhardt
  0 siblings, 1 reply; 3+ messages in thread
From: Subbaiah Venkata @ 2007-08-08 23:19 UTC (permalink / raw)
  To: linux-kernel


Hello, I fixed and tested a small bug in lib/sort.c file, heap sort
function.

The fix avoids unnecessary swap of contents when i is 0 (saves few loads and
stores),
which happens every time sort function is called. I felt the fix is worth
bringing it 
to your attention given the importance and frequent use of the sort
function.

Thank you all.

==================================================================
diff --git a/lib/sort.c b/lib/sort.c
index 9615678..6abbaf3 100644
--- a/lib/sort.c
+++ b/lib/sort.c
@@ -67,7 +67,7 @@ void sort(void *base, size_t num, size_t size,
        }

        /* sort */
-       for (i = n - size; i >= 0; i -= size) {
+       for (i = n - size; i > 0; i -= size) {
                swap(base, base + i, size);
                for (r = 0; r * 2 + size < i; r = c) {
                        c = r * 2 + size;


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] lib/sort.c, 2.6.22 kernel
  2007-08-08 23:19 [PATCH] lib/sort.c, 2.6.22 kernel Subbaiah Venkata
@ 2007-09-25 14:52 ` Jan Engelhardt
  2007-09-25 17:37   ` Matt Mackall
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Engelhardt @ 2007-09-25 14:52 UTC (permalink / raw)
  To: Subbaiah Venkata; +Cc: linux-kernel


On Aug 8 2007 16:19, Subbaiah Venkata wrote:
>
>Hello, I fixed and tested a small bug in lib/sort.c file, heap sort
>function.
>
>The fix avoids unnecessary swap of contents when i is 0 (saves few
>loads and stores), which happens every time sort function is called.
>I felt the fix is worth bringing it to your attention given the
>importance and frequent use of the sort function.

Would you like to resubmit this? Please do ;)
(I am hinting at Documentation/SubmittingPatches too..)


>==================================================================
>diff --git a/lib/sort.c b/lib/sort.c
>index 9615678..6abbaf3 100644
>--- a/lib/sort.c
>+++ b/lib/sort.c
>@@ -67,7 +67,7 @@ void sort(void *base, size_t num, size_t size,
>        }
>
>        /* sort */
>-       for (i = n - size; i >= 0; i -= size) {
>+       for (i = n - size; i > 0; i -= size) {
>                swap(base, base + i, size);
>                for (r = 0; r * 2 + size < i; r = c) {
>                        c = r * 2 + size;
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] lib/sort.c, 2.6.22 kernel
  2007-09-25 14:52 ` Jan Engelhardt
@ 2007-09-25 17:37   ` Matt Mackall
  0 siblings, 0 replies; 3+ messages in thread
From: Matt Mackall @ 2007-09-25 17:37 UTC (permalink / raw)
  To: Jan Engelhardt; +Cc: Subbaiah Venkata, linux-kernel

On Tue, Sep 25, 2007 at 04:52:47PM +0200, Jan Engelhardt wrote:
> 
> On Aug 8 2007 16:19, Subbaiah Venkata wrote:
> >
> >Hello, I fixed and tested a small bug in lib/sort.c file, heap sort
> >function.
> >
> >The fix avoids unnecessary swap of contents when i is 0 (saves few
> >loads and stores), which happens every time sort function is called.
> >I felt the fix is worth bringing it to your attention given the
> >importance and frequent use of the sort function.
> 
> Would you like to resubmit this? Please do ;)
> (I am hinting at Documentation/SubmittingPatches too..)

This is in -mm already.

-- 
Mathematics is the supreme nostalgia of our time.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-09-25 17:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-08 23:19 [PATCH] lib/sort.c, 2.6.22 kernel Subbaiah Venkata
2007-09-25 14:52 ` Jan Engelhardt
2007-09-25 17:37   ` Matt Mackall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox