From: "Subbaiah Venkata" <kvsnaidu@sapnaidu.net>
To: <linux-kernel@vger.kernel.org>
Subject: [PATCH] lib/sort.c, 2.6.22 kernel
Date: Wed, 8 Aug 2007 16:19:55 -0700 [thread overview]
Message-ID: <000201c7da12$a1aec340$0a02a8c0@NetWin> (raw)
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;
next reply other threads:[~2007-08-08 20:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-08 23:19 Subbaiah Venkata [this message]
2007-09-25 14:52 ` [PATCH] lib/sort.c, 2.6.22 kernel Jan Engelhardt
2007-09-25 17:37 ` Matt Mackall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='000201c7da12$a1aec340$0a02a8c0@NetWin' \
--to=kvsnaidu@sapnaidu.net \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.