Re: [PATCH v3 3/3] UefiCpuPkg/CpuCacheInfoLib: Add QuickSort function on BaseLib


Ni, Ray
 

Ian,
Thanks for cleaning up the code to remove MdeModulePkg dependency.

Minor comments below:

UINTN NextIndex;
+ VOID *QuickSortBuffer;

1. Can you use local variable? "CPU_CACHE_INFO SortBuffer".


- PerformQuickSort (LocalCacheInfo, LocalCacheInfoCount, sizeof (*LocalCacheInfo), (SORT_COMPARE) CpuCacheInfoCompare);
+ QuickSortBuffer = AllocateZeroPool (sizeof (*LocalCacheInfo));
+ if (QuickSortBuffer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }

2. With #1 change, you can avoid "calling AllocateZeroPool() and checking pointer".

+ QuickSort (LocalCacheInfo, LocalCacheInfoCount, sizeof (*LocalCacheInfo), CpuCacheInfoCompare, QuickSortBuffer);

3. Just pass "&SortBuffer" as the last parameter.

Join devel@edk2.groups.io to automatically receive all group messages.