GP-5917 Use a hashset for functions to reduce reduntant decompiler use

in functions that have more than one possible switch
This commit is contained in:
emteere 2025-08-07 12:59:34 +00:00 committed by Ryan Kurtz
parent 0a436cbc4b
commit 48adb5ec25

View file

@ -57,7 +57,7 @@ public class DecompilerSwitchAnalyzer extends AbstractAnalyzer {
// cache for pcode callother injection payloads // cache for pcode callother injection payloads
private HashMap<Long, InjectPayload> injectPayloadCache = new HashMap<>(); private HashMap<Long, InjectPayload> injectPayloadCache = new HashMap<>();
private boolean hitNonReturningFunction = false; private boolean hitNonReturningThunkFunction = false;
//================================================================================================== //==================================================================================================
@ -103,12 +103,12 @@ public class DecompilerSwitchAnalyzer extends AbstractAnalyzer {
return true; return true;
} }
List<Function> definedFunctions = new ArrayList<>(); Collection<Function> definedFunctions = new HashSet<>();
List<Function> undefinedFunctions = new ArrayList<>(); Collection<Function> undefinedFunctions = new HashSet<>();
findFunctions(program, locations, definedFunctions, undefinedFunctions, monitor); findFunctions(program, locations, definedFunctions, undefinedFunctions, monitor);
if (hitNonReturningFunction) { if (hitNonReturningThunkFunction) {
hitNonReturningFunction = false; hitNonReturningThunkFunction = false;
// if hit a non-returning function, code needs to be fixed up // if hit a non-returning function, code needs to be fixed up
// before wasting time on analyzing potentially bad code // before wasting time on analyzing potentially bad code
// This will also clean out locations that were thunks for the next go round. // This will also clean out locations that were thunks for the next go round.
@ -209,8 +209,9 @@ public class DecompilerSwitchAnalyzer extends AbstractAnalyzer {
} }
// kids, don't do thunks // kids, don't do thunks
if (function.isThunk()) { if (function.isThunk()) {
// unless they are non-returning
if (function.hasNoReturn()) { if (function.hasNoReturn()) {
hitNonReturningFunction = true; hitNonReturningThunkFunction = true;
} }
continue; continue;
} }
@ -428,7 +429,7 @@ public class DecompilerSwitchAnalyzer extends AbstractAnalyzer {
program.getFunctionManager().getFunctionContaining(location); program.getFunctionManager().getFunctionContaining(location);
if (fixupFunc != null) { if (fixupFunc != null) {
CreateFunctionCmd.fixupFunctionBody(program, fixupFunc, monitor); CreateFunctionCmd.fixupFunctionBody(program, fixupFunc, monitor);
// send function back, so non-returning nature will be picked up by decompiler // send function back, so non-returning nature will be picked up
if (fixupFunc.hasNoReturn()) { if (fixupFunc.hasNoReturn()) {
return fixupFunc; return fixupFunc;
} }