mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 01:22:04 +00:00
Fix clang-tidy performance-inefficient-vector-operation
By some reason it appears only after static_cast<> was added [1]: /build/src/Processors/Formats/Impl/AvroRowInputFormat.cpp Oct 18 01:03:56 /build/src/Processors/Formats/Impl/AvroRowInputFormat.cpp:351:21: error: 'push_back' is called inside a loop; consider pre-allocating the container capacity before the loop [performance-inefficient-vector-operation,-warnings-as-errors] Oct 18 01:03:56 symbols.push_back(root_node->nameAt(i)); Oct 18 01:03:56 ^ Oct 18 01:03:56 /build/src/Processors/Formats/Impl/AvroRowInputFormat.cpp:511:17: error: 'push_back' is called inside a loop; consider pre-allocating the container capacity before the loop [performance-inefficient-vector-operation,-warnings-as-errors] Oct 18 01:03:56 union_skip_fns.push_back(createSkipFn(root_node->leafAt(i))); Oct 18 01:03:56 ^ Oct 18 01:03:56 /build/src/Processors/Formats/Impl/AvroRowInputFormat.cpp:552:17: error: 'push_back' is called inside a loop; consider pre-allocating the container capacity before the loop [performance-inefficient-vector-operation,-warnings-as-errors] Oct 18 01:03:56 field_skip_fns.push_back(createSkipFn(root_node->leafAt(i))); Oct 18 01:03:56 ^ Oct 18 01:03:56 197965 warnings generated. [1]: https://s3.amazonaws.com/clickhouse-builds/42190/453d91fa3539882dcef1d5ecd5097747499572d8/clickhouse_special_build_check/report.html Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
This commit is contained in:
parent
3d400068fd
commit
5094c0dd6d
@ -346,6 +346,7 @@ AvroDeserializer::DeserializeFn AvroDeserializer::createDeserializeFn(avro::Node
|
||||
if (target.isString())
|
||||
{
|
||||
std::vector<std::string> symbols;
|
||||
symbols.reserve(root_node->names());
|
||||
for (int i = 0; i < static_cast<int>(root_node->names()); ++i)
|
||||
{
|
||||
symbols.push_back(root_node->nameAt(i));
|
||||
@ -506,6 +507,7 @@ AvroDeserializer::SkipFn AvroDeserializer::createSkipFn(avro::NodePtr root_node)
|
||||
case avro::AVRO_UNION:
|
||||
{
|
||||
std::vector<SkipFn> union_skip_fns;
|
||||
union_skip_fns.reserve(root_node->leaves());
|
||||
for (int i = 0; i < static_cast<int>(root_node->leaves()); ++i)
|
||||
{
|
||||
union_skip_fns.push_back(createSkipFn(root_node->leafAt(i)));
|
||||
@ -547,6 +549,7 @@ AvroDeserializer::SkipFn AvroDeserializer::createSkipFn(avro::NodePtr root_node)
|
||||
case avro::AVRO_RECORD:
|
||||
{
|
||||
std::vector<SkipFn> field_skip_fns;
|
||||
field_skip_fns.reserve(root_node->leaves());
|
||||
for (int i = 0; i < static_cast<int>(root_node->leaves()); ++i)
|
||||
{
|
||||
field_skip_fns.push_back(createSkipFn(root_node->leafAt(i)));
|
||||
|
Loading…
Reference in New Issue
Block a user