3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 17:15:31 +00:00

Prefer using empty rather than size comparisons.

This commit is contained in:
Bruce Mitchener 2018-11-27 21:42:04 +07:00
parent a83097d5cc
commit e570940662
56 changed files with 104 additions and 104 deletions

View file

@ -183,7 +183,7 @@ template <typename T, typename X> unsigned core_solver_pretty_printer<T, X>:: ge
}
if (!m_core_solver.use_tableau()) {
w = std::max(w, (unsigned)T_to_string(m_exact_column_norms[column]).size());
if (m_core_solver.m_column_norms.size() > 0)
if (!m_core_solver.m_column_norms.empty())
w = std::max(w, (unsigned)T_to_string(m_core_solver.m_column_norms[column]).size());
}
return w;
@ -339,7 +339,7 @@ template <typename T, typename X> void core_solver_pretty_printer<T, X>::print()
print_lows();
print_upps();
print_exact_norms();
if (m_core_solver.m_column_norms.size() > 0)
if (!m_core_solver.m_column_norms.empty())
print_approx_norms();
m_out << std::endl;
}

View file

@ -81,7 +81,7 @@ void eta_matrix<T, X>::apply_from_right(vector<T> & w) {
}
template <typename T, typename X>
void eta_matrix<T, X>::apply_from_right(indexed_vector<T> & w) {
if (w.m_index.size() == 0)
if (w.m_index.empty())
return;
#ifdef Z3DEBUG
// vector<T> wcopy(w.m_data);

View file

@ -51,7 +51,7 @@ public:
unsigned row_count() const { return m_data.size(); }
unsigned column_count() const { return m_data.size() > 0? m_data[0].size() : 0; }
unsigned column_count() const { return !m_data.empty()? m_data[0].size() : 0; }
class ref_row {
general_matrix& m_matrix;

View file

@ -37,7 +37,7 @@ struct lar_term {
}
bool is_empty() const {
return m_coeffs.size() == 0; // && is_zero(m_v);
return m_coeffs.empty(); // && is_zero(m_v);
}
unsigned size() const { return static_cast<unsigned>(m_coeffs.size()); }

View file

@ -665,7 +665,7 @@ template <typename T, typename X> bool lp_dual_core_solver<T, X>::ratio_test() {
m_flipped_boxed.clear();
int initial_delta_sign = m_delta >= numeric_traits<T>::zero()? 1: -1;
do {
if (m_breakpoint_set.size() == 0) {
if (m_breakpoint_set.empty()) {
set_status_to_tentative_dual_unbounded_or_dual_unbounded();
return false;
}
@ -697,7 +697,7 @@ template <typename T, typename X> void lp_dual_core_solver<T, X>::update_d_and_x
this->m_d[j] -= m_theta_D * this->m_pivot_row[j];
}
this->m_d[m_p] = - m_theta_D;
if (m_flipped_boxed.size() > 0) {
if (!m_flipped_boxed.empty()) {
process_flipped();
update_xb_after_bound_flips();
}

View file

@ -504,7 +504,7 @@ lp_primal_core_solver<T, X>::get_bound_on_variable_and_update_leaving_precisely(
X tt = - (this->m_lower_bounds[j] - this->m_x[j]) / m;
if (numeric_traits<X>::is_neg(tt))
tt = zero_of_type<X>();
if (leavings.size() == 0 || tt < t || (tt == t && m > abs_of_d_of_leaving)) {
if (leavings.empty() || tt < t || (tt == t && m > abs_of_d_of_leaving)) {
t = tt;
abs_of_d_of_leaving = m;
leavings.clear();
@ -524,7 +524,7 @@ lp_primal_core_solver<T, X>::get_bound_on_variable_and_update_leaving_precisely(
X tt = (this->m_upper_bounds[j] - this->m_x[j]) / m;
if (numeric_traits<X>::is_neg(tt))
tt = zero_of_type<X>();
if (leavings.size() == 0 || tt < t || (tt == t && - m > abs_of_d_of_leaving)) {
if (leavings.empty() || tt < t || (tt == t && - m > abs_of_d_of_leaving)) {
t = tt;
abs_of_d_of_leaving = - m;
leavings.clear();

View file

@ -103,7 +103,7 @@ template <typename T, typename X> void lp_solver<T, X>::flip_costs() {
template <typename T, typename X> bool lp_solver<T, X>::problem_is_empty() {
for (auto & c : m_A_values)
if (c.second.size())
if (!c.second.empty())
return false;
return true;
}
@ -387,7 +387,7 @@ template <typename T, typename X> unsigned lp_solver<T, X>::try_to_remove_some_r
return 0;
}
}
if (rows_to_delete.size() > 0) {
if (!rows_to_delete.empty()) {
for (unsigned k : rows_to_delete) {
m_A_values.erase(k);
}

View file

@ -97,7 +97,7 @@ void print_matrix_with_widths(vector<vector<std::string>> & A, vector<unsigned>
void print_string_matrix(vector<vector<std::string>> & A, std::ostream & out, unsigned blanks_in_front) {
vector<unsigned> widths;
if (A.size() > 0)
if (!A.empty())
for (unsigned j = 0; j < A[0].size(); j++) {
widths.push_back(get_width_of_column(j, A));
}

View file

@ -220,7 +220,7 @@ class mps_reader {
*m_message_stream << "cannot read from file" << std::endl;
}
m_line_number++;
if (m_line.size() != 0 && m_line[0] != '*' && !all_white_space())
if (!m_line.empty() && m_line[0] != '*' && !all_white_space())
break;
}
}
@ -514,7 +514,7 @@ class mps_reader {
lp_assert(m_line.size() >= 14);
vector<std::string> bound_string = split_and_trim(m_line.substr(name_offset, m_line.size()));
if (bound_string.size() == 0) {
if (bound_string.empty()) {
set_m_ok_to_false();
(*m_message_stream) << "error at line " << m_line_number << std::endl;
throw m_line;

View file

@ -248,7 +248,7 @@ void square_sparse_matrix<T, X>::put_max_index_to_0(vector<indexed_value<T>> & r
template <typename T, typename X>
void square_sparse_matrix<T, X>::set_max_in_row(vector<indexed_value<T>> & row_vals) {
if (row_vals.size() == 0)
if (row_vals.empty())
return;
T max_val = abs(row_vals[0].m_value);
unsigned max_index = 0;
@ -386,7 +386,7 @@ bool square_sparse_matrix<T, X>::set_row_from_work_vector_and_clean_work_vector_
}
work_vec.m_index.clear();
auto & row_vals = m_rows[i0];
if (row_vals.size() == 0) {
if (row_vals.empty()) {
return false;
}
set_max_in_row(row_vals); // it helps to find larger pivots

View file

@ -381,7 +381,7 @@ char * mpn_manager::to_string(mpn_digit const * a, size_t const lng, char * buf,
div_1(t_numer, t_denom[0], &temp[0]);
div_unnormalize(t_numer, t_denom, d, &rem);
buf[j++] = '0' + rem;
while (temp.size() > 0 && temp.back() == 0)
while (!temp.empty() && temp.back() == 0)
temp.pop_back();
}
buf[j] = 0;