From 995e4286a047b32aebf8ce540908edb7fbd93f76 Mon Sep 17 00:00:00 2001 From: Subbaiah Venkata Date: Tue, 16 Oct 2007 23:27:06 -0700 Subject: 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 Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- lib/sort.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/sort.c') diff --git a/lib/sort.c b/lib/sort.c index 961567894d1..6abbaf3d585 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; -- cgit v1.2.3-70-g09d2