diff options
author | jcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-09-28 18:57:40 +0000 |
---|---|---|
committer | jcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-09-28 18:57:40 +0000 |
commit | 5dcb5355127fc8fe3a44ec4416932925f1bd9310 (patch) | |
tree | dc194d02686bd470671de40dbf19f9a14a810a97 /ShellPkg/Library | |
parent | 2f6b90fbcdfda505daaaf699d23e1f5a16414dc2 (diff) | |
download | edk2-5dcb5355127fc8fe3a44ec4416932925f1bd9310.zip edk2-5dcb5355127fc8fe3a44ec4416932925f1bd9310.tar.gz edk2-5dcb5355127fc8fe3a44ec4416932925f1bd9310.tar.bz2 |
No need to sort arrays of 1 element.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10899 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg/Library')
-rw-r--r-- | ShellPkg/Library/BaseSortLib/BaseSortLib.c | 29 | ||||
-rw-r--r-- | ShellPkg/Library/UefiSortLib/UefiSortLib.c | 28 |
2 files changed, 32 insertions, 25 deletions
diff --git a/ShellPkg/Library/BaseSortLib/BaseSortLib.c b/ShellPkg/Library/BaseSortLib/BaseSortLib.c index 2d3f190..b26d971 100644 --- a/ShellPkg/Library/BaseSortLib/BaseSortLib.c +++ b/ShellPkg/Library/BaseSortLib/BaseSortLib.c @@ -109,20 +109,23 @@ QuickSortWorker ( // Now recurse on 2 paritial lists. neither of these will have the 'pivot' element
// IE list is sorted left half, pivot element, sorted right half...
//
- QuickSortWorker(
- BufferToSort,
- NextSwapLocation,
- ElementSize,
- CompareFunction,
- Buffer);
-
- QuickSortWorker(
- (UINT8 *)BufferToSort + (NextSwapLocation+1) * ElementSize,
- Count - NextSwapLocation - 1,
- ElementSize,
- CompareFunction,
- Buffer);
+ if (NextSwapLocation >= 2) {
+ QuickSortWorker(
+ BufferToSort,
+ NextSwapLocation,
+ ElementSize,
+ CompareFunction,
+ Buffer);
+ }
+ if ((Count - NextSwapLocation - 1) >= 2) {
+ QuickSortWorker(
+ (UINT8 *)BufferToSort + (NextSwapLocation+1) * ElementSize,
+ Count - NextSwapLocation - 1,
+ ElementSize,
+ CompareFunction,
+ Buffer);
+ }
return;
}
/**
diff --git a/ShellPkg/Library/UefiSortLib/UefiSortLib.c b/ShellPkg/Library/UefiSortLib/UefiSortLib.c index 7cbff34..62d6eaa 100644 --- a/ShellPkg/Library/UefiSortLib/UefiSortLib.c +++ b/ShellPkg/Library/UefiSortLib/UefiSortLib.c @@ -118,19 +118,23 @@ QuickSortWorker ( // Now recurse on 2 paritial lists. neither of these will have the 'pivot' element
// IE list is sorted left half, pivot element, sorted right half...
//
- QuickSortWorker(
- BufferToSort,
- NextSwapLocation,
- ElementSize,
- CompareFunction,
- Buffer);
+ if (NextSwapLocation >= 2) {
+ QuickSortWorker(
+ BufferToSort,
+ NextSwapLocation,
+ ElementSize,
+ CompareFunction,
+ Buffer);
+ }
- QuickSortWorker(
- (UINT8 *)BufferToSort + (NextSwapLocation+1) * ElementSize,
- Count - NextSwapLocation - 1,
- ElementSize,
- CompareFunction,
- Buffer);
+ if ((Count - NextSwapLocation - 1) >= 2) {
+ QuickSortWorker(
+ (UINT8 *)BufferToSort + (NextSwapLocation+1) * ElementSize,
+ Count - NextSwapLocation - 1,
+ ElementSize,
+ CompareFunction,
+ Buffer);
+ }
return;
}
|