Skip to content

Commit

Permalink
clang-tidy: performance-inefficient-vector-operation (#7471)
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Argueta <dereka@pinterest.com>
  • Loading branch information
derekargueta authored and mattklein123 committed Jul 5, 2019
1 parent 733052a commit 4af0c54
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ WarningsAsErrors: 'abseil-duration-*,
modernize-use-using,
performance-faster-string-find,
performance-for-range-copy,
performance-inefficient-vector-operation,
performance-noexcept-move-constructor,
performance-unnecessary-copy-initialization,
readability-braces-around-statements,
Expand Down
1 change: 1 addition & 0 deletions source/server/http/admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,7 @@ std::string PrometheusStatsFormatter::sanitizeName(const std::string& name) {

std::string PrometheusStatsFormatter::formattedTags(const std::vector<Stats::Tag>& tags) {
std::vector<std::string> buf;
buf.reserve(tags.size());
for (const Stats::Tag& tag : tags) {
buf.push_back(fmt::format("{}=\"{}\"", sanitizeName(tag.name_), tag.value_));
}
Expand Down
1 change: 1 addition & 0 deletions test/integration/integration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ void BaseIntegrationTest::createEnvoy() {

std::vector<std::string> named_ports;
const auto& static_resources = config_helper_.bootstrap().static_resources();
named_ports.reserve(static_resources.listeners_size());
for (int i = 0; i < static_resources.listeners_size(); ++i) {
named_ports.push_back(static_resources.listeners(i).name());
}
Expand Down
6 changes: 3 additions & 3 deletions test/server/options_impl_test.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <algorithm>
#include <chrono>
#include <fstream>
#include <memory>
Expand Down Expand Up @@ -37,9 +38,8 @@ class OptionsImplTest : public testing::Test {
std::unique_ptr<OptionsImpl> createOptionsImpl(const std::string& args) {
std::vector<std::string> words = TestUtility::split(args, ' ');
std::vector<const char*> argv;
for (const std::string& s : words) {
argv.push_back(s.c_str());
}
std::transform(words.cbegin(), words.cend(), std::back_inserter(argv),
[](const std::string& arg) { return arg.c_str(); });
return std::make_unique<OptionsImpl>(
argv.size(), argv.data(), [](bool) { return "1"; }, spdlog::level::warn);
}
Expand Down

0 comments on commit 4af0c54

Please sign in to comment.