Factor the profitability check for return slot optimization out into a static function.