Skip to content

Commit fd3a72a

Browse files
authored
clang-tidy update + small fixes (#831)
1 parent 13ead9b commit fd3a72a

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

.clang-tidy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Checks: '
3232
-bugprone-reserved-identifier,
3333
-bugprone-signed-char-misuse,
3434
-bugprone-suspicious-include,
35+
-bugprone-unchecked-optional-access,
3536
-bugprone-unhandled-self-assignment,
3637
-clang-analyzer-cplusplus.NewDelete,
3738
-clang-analyzer-cplusplus.NewDeleteLeaks,

src/binder/fmt_impl.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ auto BoundCTERef::ToString() const -> std::string {
4545
}
4646

4747
auto BoundSubqueryRef::ToString() const -> std::string {
48-
std::vector<std::string> columns(select_list_name_.size());
48+
std::vector<std::string> columns;
49+
columns.reserve(select_list_name_.size());
4950
for (const auto &name : select_list_name_) {
5051
columns.push_back(fmt::format("{}", fmt::join(name, ".")));
5152
}
@@ -54,12 +55,14 @@ auto BoundSubqueryRef::ToString() const -> std::string {
5455
}
5556

5657
auto BoundWindow::ToString() const -> std::string {
57-
std::vector<std::string> partition_by(partition_by_.size());
58+
std::vector<std::string> partition_by;
59+
partition_by.reserve(partition_by_.size());
5860
for (const auto &expr : partition_by_) {
5961
partition_by.push_back(expr->ToString());
6062
}
6163

62-
std::vector<std::string> order_bys(order_bys_.size());
64+
std::vector<std::string> order_bys;
65+
order_bys.reserve(order_bys_.size());
6366
for (const auto &expr : order_bys_) {
6467
order_bys.push_back(expr->ToString());
6568
}

src/catalog/table_generator.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ void TableGenerator::FillTable(const std::shared_ptr<TableInfo> &info, TableInse
7878
uint32_t num_inserted = 0;
7979
uint32_t batch_size = 128;
8080
while (num_inserted < table_meta->num_rows_) {
81-
std::vector<std::vector<Value>> values(table_meta->col_meta_.size());
81+
std::vector<std::vector<Value>> values;
82+
values.reserve(table_meta->col_meta_.size());
8283
uint32_t num_values = std::min(batch_size, table_meta->num_rows_ - num_inserted);
8384
for (auto &col_meta : table_meta->col_meta_) {
8485
values.emplace_back(MakeValues(&col_meta, num_values));

src/include/catalog/catalog.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,8 @@ class Catalog {
360360
}
361361

362362
auto GetTableNames() -> std::vector<std::string> {
363-
std::vector<std::string> result(table_names_.size());
363+
std::vector<std::string> result;
364+
result.reserve(table_names_.size());
364365
for (const auto &x : table_names_) {
365366
result.push_back(x.first);
366367
}

0 commit comments

Comments
 (0)