]> git.proxmox.com Git - mirror_edk2.git/commitdiff
No need to sort arrays of 1 element.
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 28 Sep 2010 18:57:40 +0000 (18:57 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 28 Sep 2010 18:57:40 +0000 (18:57 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10899 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Library/BaseSortLib/BaseSortLib.c
ShellPkg/Library/UefiSortLib/UefiSortLib.c

index 2d3f190324d708793072af25e8566aabf01a1c13..b26d97127073e334a72e000a48e084f04095effb 100644 (file)
@@ -109,20 +109,23 @@ QuickSortWorker (
   // Now recurse on 2 paritial lists.  neither of these will have the 'pivot' element\r
   // IE list is sorted left half, pivot element, sorted right half...\r
   //\r
-  QuickSortWorker(\r
-    BufferToSort,\r
-    NextSwapLocation,\r
-    ElementSize,\r
-    CompareFunction,\r
-    Buffer);\r
-\r
-  QuickSortWorker(\r
-    (UINT8 *)BufferToSort + (NextSwapLocation+1) * ElementSize,\r
-    Count - NextSwapLocation - 1,\r
-    ElementSize,\r
-    CompareFunction,\r
-    Buffer);\r
+  if (NextSwapLocation >= 2) {\r
+    QuickSortWorker(\r
+      BufferToSort,\r
+      NextSwapLocation,\r
+      ElementSize,\r
+      CompareFunction,\r
+      Buffer);\r
+  }\r
 \r
+  if ((Count - NextSwapLocation - 1) >= 2) {\r
+    QuickSortWorker(\r
+      (UINT8 *)BufferToSort + (NextSwapLocation+1) * ElementSize,\r
+      Count - NextSwapLocation - 1,\r
+      ElementSize,\r
+      CompareFunction,\r
+      Buffer);\r
+  }\r
   return;\r
 }\r
 /**\r
index 7cbff34cca11fb39dbb899d99a958005f1143824..62d6eaabb8067da434bdb0e15502ce1a7be16562 100644 (file)
@@ -118,19 +118,23 @@ QuickSortWorker (
   // Now recurse on 2 paritial lists.  neither of these will have the 'pivot' element\r
   // IE list is sorted left half, pivot element, sorted right half...\r
   //\r
-  QuickSortWorker(\r
-    BufferToSort,\r
-    NextSwapLocation,\r
-    ElementSize,\r
-    CompareFunction,\r
-    Buffer);\r
+  if (NextSwapLocation >= 2) {\r
+    QuickSortWorker(\r
+      BufferToSort,\r
+      NextSwapLocation,\r
+      ElementSize,\r
+      CompareFunction,\r
+      Buffer);\r
+  }\r
 \r
-  QuickSortWorker(\r
-    (UINT8 *)BufferToSort + (NextSwapLocation+1) * ElementSize,\r
-    Count - NextSwapLocation - 1,\r
-    ElementSize,\r
-    CompareFunction,\r
-    Buffer);\r
+  if ((Count - NextSwapLocation - 1) >= 2) {\r
+    QuickSortWorker(\r
+      (UINT8 *)BufferToSort + (NextSwapLocation+1) * ElementSize,\r
+      Count - NextSwapLocation - 1,\r
+      ElementSize,\r
+      CompareFunction,\r
+      Buffer);\r
+  }\r
 \r
   return;\r
 }\r