Skip to content

Commit 4b661e4

Browse files
Keenan GugelerRiolku
authored andcommitted
tidy: enable performance checks
With the exception of performance-no-int-to-ptr, this change enables clang tidy's performance-based lints. The changes made are as follows, in no particular order. - Avoid std::endl. std::endl is confusing because it also flushes the buffer, which is often undesirable. Instead, we should just use a newline character. - When possible, declare variables as `const T&` instead of `T`, since it avoids a copy. - When possible, use `std::move` to avoid a copy. However, if the type is trivially copyable, `std::move` does nothing and hence should be removed. Furthermore, if the variable to be moved is constant, `std::move` simply copies, and so `std::move` is confusing and should be removed. Finally, if the variable is moved, but the function parameter type is `const T&`, then a move is unnecessary, and again, it should be removed. - When using `push_back` in a loop, we should reserve up front for better performance. - When concatenating strings, either we should `std::move()` the strings, or use `string::append`. Otherwise, we pay the price of creating temporary strings, instead of just pushing to a single string. - Trivial destructors should be declared with `= default` to allow more aggressive compiler optimizations.
1 parent 9f24b07 commit 4b661e4

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src_cpp/include/node_connection.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#pragma once
22

3+
#include <utility>
4+
35
#include "main/kuzu.h"
46
#include "node_database.h"
57
#include "node_prepared_statement.h"
@@ -64,7 +66,7 @@ class ConnectionExecuteAsyncWorker : public Napi::AsyncWorker {
6466
ConnectionExecuteAsyncWorker(Napi::Function& callback, std::shared_ptr<Connection>& connection,
6567
std::shared_ptr<PreparedStatement> preparedStatement, NodeQueryResult* nodeQueryResult,
6668
std::unordered_map<std::string, std::unique_ptr<Value>> params)
67-
: Napi::AsyncWorker(callback), preparedStatement(preparedStatement),
69+
: Napi::AsyncWorker(callback), preparedStatement(std::move(preparedStatement)),
6870
nodeQueryResult(nodeQueryResult), connection(connection), params(std::move(params)) {}
6971
~ConnectionExecuteAsyncWorker() override = default;
7072

0 commit comments

Comments
 (0)