From: Subbaiah Venkata Date: Wed, 17 Oct 2007 06:27:06 +0000 (-0700) Subject: lib/sort.c optimization X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=995e4286a047b32aebf8ce540908edb7fbd93f76;p=GitHub%2FLineageOS%2Fandroid_kernel_samsung_universal7580.git 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 --- 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;