Modernize code (clang-tidy -checks='-*,modernize-use-emplace')

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2021-03-22 08:39:40 +01:00
parent a54dc6390d
commit 2a83c4a898
5 changed files with 22 additions and 22 deletions

View File

@ -287,8 +287,8 @@ TEST_F(TesseractTest, InitConfigOnlyTest) {
}
// Init variables to set for config-only initialization.
std::vector<std::string> vars_vec, vars_values;
vars_vec.push_back("tessedit_init_config_only");
vars_values.push_back("1");
vars_vec.emplace_back("tessedit_init_config_only");
vars_values.emplace_back("1");
LOG(INFO) << "Switching to config only initialization:";
for (auto &lang : langs) {
api = std::make_unique<tesseract::TessBaseAPI>();

View File

@ -71,9 +71,9 @@ protected:
if (FLAGS_test_tesseract) {
int i = 0;
while (kTessLangs[i] && kTessTruthText[i] && kTessImages[i]) {
langs_.push_back(kTessLangs[i]);
gt_text_.push_back(kTessTruthText[i]);
image_files.push_back(kTessImages[i]);
langs_.emplace_back(kTessLangs[i]);
gt_text_.emplace_back(kTessTruthText[i]);
image_files.emplace_back(kTessImages[i]);
++i;
}
LOG(INFO) << "Testing Tesseract on " << i << " languages.";
@ -81,9 +81,9 @@ protected:
if (FLAGS_test_cube) {
int i = 0;
while (kCubeLangs[i] && kCubeTruthText[i] && kCubeImages[i]) {
langs_.push_back(kCubeLangs[i]);
gt_text_.push_back(kCubeTruthText[i]);
image_files.push_back(kCubeImages[i]);
langs_.emplace_back(kCubeLangs[i]);
gt_text_.emplace_back(kCubeTruthText[i]);
image_files.emplace_back(kCubeImages[i]);
++i;
}
LOG(INFO) << "Testing Cube on " << i << " languages.";

View File

@ -103,11 +103,11 @@ TEST_F(LLSQTest, Vectors) {
// sqrt( sum (!nvec * (x_i - x_avg))^2 / n)
TEST_F(LLSQTest, RmsOrthWorksAsIntended) {
std::vector<FCOORD> pts;
pts.push_back(FCOORD(0.56, 0.95));
pts.push_back(FCOORD(0.09, 0.09));
pts.push_back(FCOORD(0.13, 0.77));
pts.push_back(FCOORD(0.16, 0.83));
pts.push_back(FCOORD(0.45, 0.79));
pts.emplace_back(0.56, 0.95);
pts.emplace_back(0.09, 0.09);
pts.emplace_back(0.13, 0.77);
pts.emplace_back(0.16, 0.83);
pts.emplace_back(0.45, 0.79);
VerifyRmsOrth(pts, FCOORD(1, 0));
VerifyRmsOrth(pts, FCOORD(1, 1));
VerifyRmsOrth(pts, FCOORD(1, 2));

View File

@ -92,7 +92,7 @@ protected:
EXPECT_TRUE(
trainer_->InitNetwork(network_spec.c_str(), -1, net_mode, 0.1, learning_rate, 0.9, 0.999));
std::vector<std::string> filenames;
filenames.push_back(std::string(TestDataNameToPath(lstmf_file).c_str()));
filenames.emplace_back(TestDataNameToPath(lstmf_file).c_str());
EXPECT_TRUE(trainer_->LoadAllTrainingData(filenames, CS_SEQUENTIAL, false));
LOG(INFO) << "Setup network:" << model_name << "\n";
}

View File

@ -148,9 +148,9 @@ void EvaluateParagraphDetection(const TextAndModel *correct, int n,
EXPECT_EQ(bad_crowns, 0);
if (incorrect_breaks || missed_breaks || poorly_matched_models || bad_list_items || bad_crowns) {
std::vector<std::string> dbg_lines;
dbg_lines.push_back("# ==========================");
dbg_lines.push_back("# Correct paragraph breaks:");
dbg_lines.push_back("# ==========================");
dbg_lines.emplace_back("# ==========================");
dbg_lines.emplace_back("# Correct paragraph breaks:");
dbg_lines.emplace_back("# ==========================");
for (int i = 0; i < n; i++) {
if (correct[i].model_type != PCONT) {
dbg_lines.push_back(absl::StrCat(correct[i].ascii, " # ",
@ -158,13 +158,13 @@ void EvaluateParagraphDetection(const TextAndModel *correct, int n,
correct[i].is_very_first_or_continuation ? " crown" : "",
correct[i].is_list_item ? " li" : ""));
} else {
dbg_lines.push_back(correct[i].ascii);
dbg_lines.emplace_back(correct[i].ascii);
}
}
dbg_lines.push_back("");
dbg_lines.push_back("# ==========================");
dbg_lines.push_back("# Paragraph detector output:");
dbg_lines.push_back("# ==========================");
dbg_lines.emplace_back("");
dbg_lines.emplace_back("# ==========================");
dbg_lines.emplace_back("# Paragraph detector output:");
dbg_lines.emplace_back("# ==========================");
for (int i = 0; i < n; i++) {
std::string annotation;
if (i == 0 || (detector_output[i - 1] != detector_output[i])) {