Fix some clang-tidy warnings. Change-Id: Ic71bf0fc561edc22e3051d156fac630fcfea5d92
diff --git a/internal/ceres/reorder_program_test.cc b/internal/ceres/reorder_program_test.cc index a3e2c78..f7f67aa 100644 --- a/internal/ceres/reorder_program_test.cc +++ b/internal/ceres/reorder_program_test.cc
@@ -70,12 +70,12 @@ problem.AddParameterBlock(&y, 1); problem.AddParameterBlock(&z, 1); - problem.AddResidualBlock(new UnaryCostFunction(), NULL, &x); - problem.AddResidualBlock(new BinaryCostFunction(), NULL, &z, &x); - problem.AddResidualBlock(new BinaryCostFunction(), NULL, &z, &y); - problem.AddResidualBlock(new UnaryCostFunction(), NULL, &z); - problem.AddResidualBlock(new BinaryCostFunction(), NULL, &x, &y); - problem.AddResidualBlock(new UnaryCostFunction(), NULL, &y); + problem.AddResidualBlock(new UnaryCostFunction(), nullptr, &x); + problem.AddResidualBlock(new BinaryCostFunction(), nullptr, &z, &x); + problem.AddResidualBlock(new BinaryCostFunction(), nullptr, &z, &y); + problem.AddResidualBlock(new UnaryCostFunction(), nullptr, &z); + problem.AddResidualBlock(new BinaryCostFunction(), nullptr, &x, &y); + problem.AddResidualBlock(new UnaryCostFunction(), nullptr, &y); ParameterBlockOrdering* linear_solver_ordering = new ParameterBlockOrdering; linear_solver_ordering->AddElementToGroup(&x, 0); @@ -173,12 +173,12 @@ public ::testing::Test { protected: void SetUp() { - problem_.AddResidualBlock(new UnaryCostFunction(), NULL, &x_); - problem_.AddResidualBlock(new BinaryCostFunction(), NULL, &z_, &x_); - problem_.AddResidualBlock(new BinaryCostFunction(), NULL, &z_, &y_); - problem_.AddResidualBlock(new UnaryCostFunction(), NULL, &z_); - problem_.AddResidualBlock(new BinaryCostFunction(), NULL, &x_, &y_); - problem_.AddResidualBlock(new UnaryCostFunction(), NULL, &y_); + problem_.AddResidualBlock(new UnaryCostFunction(), nullptr, &x_); + problem_.AddResidualBlock(new BinaryCostFunction(), nullptr, &z_, &x_); + problem_.AddResidualBlock(new BinaryCostFunction(), nullptr, &z_, &y_); + problem_.AddResidualBlock(new UnaryCostFunction(), nullptr, &z_); + problem_.AddResidualBlock(new BinaryCostFunction(), nullptr, &x_, &y_); + problem_.AddResidualBlock(new UnaryCostFunction(), nullptr, &y_); } void ComputeAndValidateOrdering( @@ -260,12 +260,12 @@ problem.AddParameterBlock(&y, 1); problem.AddParameterBlock(&z, 1); - problem.AddResidualBlock(new UnaryCostFunction(), NULL, &x); - problem.AddResidualBlock(new BinaryCostFunction(), NULL, &z, &x); - problem.AddResidualBlock(new BinaryCostFunction(), NULL, &z, &y); - problem.AddResidualBlock(new UnaryCostFunction(), NULL, &z); - problem.AddResidualBlock(new BinaryCostFunction(), NULL, &x, &y); - problem.AddResidualBlock(new UnaryCostFunction(), NULL, &y); + problem.AddResidualBlock(new UnaryCostFunction(), nullptr, &x); + problem.AddResidualBlock(new BinaryCostFunction(), nullptr, &z, &x); + problem.AddResidualBlock(new BinaryCostFunction(), nullptr, &z, &y); + problem.AddResidualBlock(new UnaryCostFunction(), nullptr, &z); + problem.AddResidualBlock(new BinaryCostFunction(), nullptr, &x, &y); + problem.AddResidualBlock(new UnaryCostFunction(), nullptr, &y); std::vector<ResidualBlockId> residual_block_ids; problem.GetResidualBlocks(&residual_block_ids);
diff --git a/internal/ceres/solver.cc b/internal/ceres/solver.cc index b22a5e1..861d8d3 100644 --- a/internal/ceres/solver.cc +++ b/internal/ceres/solver.cc
@@ -198,7 +198,7 @@ } } - if (options.trust_region_minimizer_iterations_to_dump.size() > 0 && + if (!options.trust_region_minimizer_iterations_to_dump.empty() && options.trust_region_problem_dump_format_type != CONSOLE && options.trust_region_problem_dump_directory.empty()) { *error = "Solver::Options::trust_region_problem_dump_directory is empty."; @@ -219,7 +219,7 @@ if (options.linear_solver_type == CGNR && options.preconditioner_type == SUBSET && - options.residual_blocks_for_subset_preconditioner.size() == 0) { + options.residual_blocks_for_subset_preconditioner.empty()) { *error = "When using SUBSET preconditioner, " "Solver::Options::residual_blocks_for_subset_preconditioner cannot be " @@ -285,7 +285,7 @@ #undef OPTION_LT_OPTION void StringifyOrdering(const vector<int>& ordering, string* report) { - if (ordering.size() == 0) { + if (ordering.empty()) { internal::StringAppendF(report, "AUTOMATIC"); return; }
diff --git a/internal/ceres/trust_region_preprocessor.cc b/internal/ceres/trust_region_preprocessor.cc index 498752b..65dee8a 100644 --- a/internal/ceres/trust_region_preprocessor.cc +++ b/internal/ceres/trust_region_preprocessor.cc
@@ -251,7 +251,7 @@ } pp->linear_solver.reset(LinearSolver::Create(pp->linear_solver_options)); - return (pp->linear_solver.get() != nullptr); + return (pp->linear_solver != nullptr); } // Configure and create the evaluator. @@ -277,7 +277,7 @@ pp->reduced_program.get(), &pp->error)); - return (pp->evaluator.get() != nullptr); + return (pp->evaluator != nullptr); } // If the user requested inner iterations, then find an inner @@ -303,7 +303,7 @@ return true; } - if (options.inner_iteration_ordering.get() != nullptr) { + if (options.inner_iteration_ordering != nullptr) { // If the user supplied an ordering, then remove the set of // inactive parameter blocks from it options.inner_iteration_ordering->Remove(pp->removed_parameter_blocks);