Took an initial crack at solving the real problem and while I still need to go back and make some changes elsewhere in the program to make this do the right thing all the time, the test cases I've been using to diagnose the performance issue are now finishing in about a tenth of a second instead of taking almost a minute and that's honestly good enough.
Shaved off a good chunk of the performance issues currently preventing the next release of CRUCS. It's not the real performance bottleneck (which has been identified) but these were easy changes that will still be nice to have later whereas the real fix is going to be somewhat more involved. Sadly, the profiler didn't show what I was hoping the bottleneck would have been as had what my first guess was been right it would have been a much easier fix.
The other trick the cat tried was seeing if she could get back in her travel box and if that would summon me.
Author of Typica software for coffee roasters.