So looking at what is left of this function after your first patch I'd be tempted to just open code it. Right now it has two callsites which either to udqp/gdqp or pdqp, althoug with your late changes we're even down to one. And the current callers kinda duplicate the checks in it, I need to look at the new code in a little more detail, though.