srctree

Robin Linden parent f39f5b2e 53568742
meta: Enable clang-tidy's performance-* checks

inlinesplit
.clang-tidy added: 27, removed: 18, total 9
@@ -39,11 +39,16 @@
#
# -modernize-use-trailing-return-type: Stylistic change, and something we
# haven't been doing so far.
#
# -performance-move-const-arg: Having to know which types are trivially copyable
# seems like unnecessary effort when calling std::move on them isn't really
# harmful.
Checks: >
bugprone-*,
google-*,
misc-*,
modernize-*,
performance-*,
readability-identifier-naming,
readability-inconsistent-declaration-parameter-name,
readability-qualified-auto,
@@ -61,6 +66,7 @@ Checks: >
-modernize-use-emplace,
-modernize-use-nodiscard,
-modernize-use-trailing-return-type,
-performance-move-const-arg,
 
WarningsAsErrors: "*"
 
 
css2/tokenizer_test.cpp added: 27, removed: 18, total 9
@@ -41,8 +41,9 @@ TokenizerOutput run_tokenizer(std::string_view input, etest::source_location loc
return {std::move(tokens), std::move(errors), std::move(loc)};
}
 
void expect_token(
TokenizerOutput &output, Token t, etest::source_location const &loc = etest::source_location::current()) {
void expect_token(TokenizerOutput &output,
Token const &t,
etest::source_location const &loc = etest::source_location::current()) {
require(!output.tokens.empty(), "Unexpected end of token list", loc);
expect_eq(output.tokens.front(), t, {}, loc);
output.tokens.erase(begin(output.tokens));
 
dom/dom.h added: 27, removed: 18, total 9
@@ -70,7 +70,7 @@ inline std::vector<T const *> nodes_by_xpath(T const &root, std::string_view xpa
}
 
auto remove_name_segment = [&] {
std::size_t separator_position{xpath.find_first_of("/")};
std::size_t separator_position{xpath.find_first_of('/')};
if (separator_position == std::string_view::npos) {
xpath = std::string_view{};
return;
 
dom2/node.cpp added: 27, removed: 18, total 9
@@ -36,7 +36,7 @@ std::shared_ptr<Node> Node::pre_insert(std::shared_ptr<Node> node, Node const *c
}
 
// https://dom.spec.whatwg.org/#concept-node-insert
void Node::insert(std::shared_ptr<Node> node, Node const *child, [[maybe_unused]] bool suppress_observers) {
void Node::insert(std::shared_ptr<Node> const &node, Node const *child, [[maybe_unused]] bool suppress_observers) {
// 1. Let nodes be node's children, if node is a DocumentFragment node; otherwise « node ».
auto const &nodes =
node->type() == NodeType::DocumentFragment ? node->child_nodes() : std::vector<std::shared_ptr<Node>>{node};
 
dom2/node.h added: 27, removed: 18, total 9
@@ -53,7 +53,7 @@ private:
std::vector<std::shared_ptr<Node>> child_nodes_{};
 
std::shared_ptr<Node> pre_insert(std::shared_ptr<Node> node, Node const *child);
void insert(std::shared_ptr<Node> node, Node const *child, bool suppress_observers = false);
void insert(std::shared_ptr<Node> const &node, Node const *child, bool suppress_observers = false);
};
 
} // namespace dom2
 
engine/engine.cpp added: 27, removed: 18, total 9
@@ -135,6 +135,7 @@ void Engine::on_navigation_success() {
// Start downloading all stylesheets.
spdlog::info("Loading {} stylesheets", head_links.size());
std::vector<std::future<std::vector<css::Rule>>> future_new_rules;
future_new_rules.reserve(head_links.size());
for (auto const *link : head_links) {
future_new_rules.push_back(std::async(std::launch::async, [=, this]() -> std::vector<css::Rule> {
auto const &href = link->attributes.at("href");
 
html2/tokenizer_test.cpp added: 27, removed: 18, total 9
@@ -73,8 +73,9 @@ TokenizerOutput run_tokenizer(std::string_view input,
return {std::move(tokens), std::move(errors), std::move(loc)};
}
 
void expect_token(
TokenizerOutput &output, Token t, etest::source_location const &loc = etest::source_location::current()) {
void expect_token(TokenizerOutput &output,
Token const &t,
etest::source_location const &loc = etest::source_location::current()) {
require(!output.tokens.empty(), "Unexpected end of token list", loc);
expect_eq(output.tokens.front(), t, {}, loc);
output.tokens.erase(begin(output.tokens));
 
html2/tree_constructor.cpp added: 27, removed: 18, total 9
@@ -181,7 +181,7 @@ std::shared_ptr<dom2::Element> TreeConstructor::create_element([[maybe_unused]]
std::shared_ptr<dom2::Element> result{nullptr};
 
// TODO(robinlinden): Everything.
result = std::make_shared<dom2::Element>(local_name);
result = std::make_shared<dom2::Element>(std::move(local_name));
 
return result;
}
 
js/ast_executor_test.cpp added: 27, removed: 18, total 9
@@ -59,7 +59,7 @@ int main() {
 
etest::test("the ast is copyable", [] {
Program p1;
auto p2 = p1;
auto p2 = p1; // NOLINT(performance-unnecessary-copy-initialization)
std::ignore = p2;
});