Skip to content

Ghidra is a software reverse engineering (SRE) framework

GT-3261: Improving sort

Ryan Kurtz370e909a557a
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/SymbolTableCommand.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/SymbolTableCommand.java
index 5bdca403cc..5a2cfbcc78 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/SymbolTableCommand.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/SymbolTableCommand.java
@@ -86,8 +86,8 @@ public class SymbolTableCommand extends LoadCommand {
// sort the entries by the index in the string table, so don't jump around reading
List<NList> sortedList = nlistList
.stream()
- .sorted((o1, o2) -> Integer.valueOf(o1.getStringTableIndex())
- .compareTo(Integer.valueOf(o2.getStringTableIndex())))
+ .sorted(
+ (o1, o2) -> Integer.compare(o1.getStringTableIndex(), o2.getStringTableIndex()))
.collect(Collectors.toList());
// initialize the NList strings from string table
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/dyld/DyldCacheLocalSymbolsInfo.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/dyld/DyldCacheLocalSymbolsInfo.java
index 9811e8c6f6..6ca6e50551 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/dyld/DyldCacheLocalSymbolsInfo.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/dyld/DyldCacheLocalSymbolsInfo.java
@@ -161,8 +161,8 @@ public class DyldCacheLocalSymbolsInfo implements StructConverter {
// sort the entries by the index in the string table, so don't jump around reading
List<NList> sortedList = nlistList
.stream()
- .sorted((o1, o2) -> Integer.valueOf(o1.getStringTableIndex())
- .compareTo(Integer.valueOf(o2.getStringTableIndex())))
+ .sorted((o1, o2) -> Integer.compare(o1.getStringTableIndex(),
+ o2.getStringTableIndex()))
.collect(Collectors.toList());
// initialize the NList strings from string table