> I think its possible to make it better in every case, but I haven't figured out how to do that yet.
There are some processes for which there is no one-algo-fits all solution. Rather than trying to find a general solution that is not terrible for either case but also not optimal for either case, could it be more efficient overall to try detect which case you have and apply the most suitable method?
Of course you'd still have to implement & maintain both methods, and there is the cost of the check on each use, and the higher cost if the check's heuristic sometimes picks the less optimal method - that might all add up to meaning a single method that is good enough for all but not ideal for either may still be the best option.
Unless there is a method to be found that is ideal (or reasonably close to) for all cases.
There are some processes for which there is no one-algo-fits all solution. Rather than trying to find a general solution that is not terrible for either case but also not optimal for either case, could it be more efficient overall to try detect which case you have and apply the most suitable method?
Of course you'd still have to implement & maintain both methods, and there is the cost of the check on each use, and the higher cost if the check's heuristic sometimes picks the less optimal method - that might all add up to meaning a single method that is good enough for all but not ideal for either may still be the best option.
Unless there is a method to be found that is ideal (or reasonably close to) for all cases.