refactor(kernel): replace manual sorting with std::sort

This commit is contained in:
EnderIce2 2025-04-08 02:37:22 +00:00
parent 3d87345a51
commit 764dfe67a5
Signed by: enderice2
GPG Key ID: FEB6B8A8507BA62E

View File

@ -131,24 +131,8 @@ namespace SymbolResolver
if (Symbols != nullptr && StringAddress != nullptr) if (Symbols != nullptr && StringAddress != nullptr)
{ {
size_t Index, MinimumIndex; std::sort(Symbols, Symbols + TotalEntries, [](const Elf_Sym &a, const Elf_Sym &b)
for (size_t i = 0; i < TotalEntries - 1; i++) { return a.st_value < b.st_value; });
{
MinimumIndex = i;
for (Index = i + 1; Index < TotalEntries; Index++)
{
bool condition = Symbols[Index].st_value < Symbols[MinimumIndex].st_value;
if (condition)
MinimumIndex = Index;
}
Elf_Sym tmp = Symbols[MinimumIndex];
Symbols[MinimumIndex] = Symbols[i];
Symbols[i] = tmp;
}
// std::sort(Symbols, Symbols + TotalEntries, [](const Elf_Sym &a, const Elf_Sym &b)
// { return a.st_value < b.st_value; });
while (Symbols[0].st_value == 0) while (Symbols[0].st_value == 0)
{ {