diff options
author | Subbaiah Venkata <kvsnaidu@sapnaidu.net> | 2007-10-17 08:27:06 +0200 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-17 17:42:52 +0200 |
commit | 995e4286a047b32aebf8ce540908edb7fbd93f76 (patch) | |
tree | 9c8e89d7dd7b33908ce7925df1bf7f67cade01db | |
parent | remove consolemap.h from header exports (diff) | |
download | linux-995e4286a047b32aebf8ce540908edb7fbd93f76.tar.xz linux-995e4286a047b32aebf8ce540908edb7fbd93f76.zip |
lib/sort.c optimization
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.
Acked-by: Matt Mackall <mpm@selenic.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | lib/sort.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/sort.c b/lib/sort.c index 961567894d16..6abbaf3d5858 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; |