beliefer commented on code in PR #10742:
URL:
https://github.com/apache/incubator-gluten/pull/10742#discussion_r2361555850
##########
cpp/velox/compute/VeloxPlanConverter.cc:
##########
@@ -46,27 +46,31 @@ std::shared_ptr<SplitInfo> parseScanSplitInfo(
using SubstraitFileFormatCase =
::substrait::ReadRel_LocalFiles_FileOrFiles::FileFormatCase;
auto splitInfo = std::make_shared<SplitInfo>();
- splitInfo->paths.reserve(fileList.size());
- splitInfo->starts.reserve(fileList.size());
- splitInfo->lengths.reserve(fileList.size());
- splitInfo->partitionColumns.reserve(fileList.size());
- splitInfo->properties.reserve(fileList.size());
- splitInfo->metadataColumns.reserve(fileList.size());
+ const size_t fileCount = fileList.size();
+
+ splitInfo->paths.reserve(fileCount);
+ splitInfo->starts.reserve(fileCount);
+ splitInfo->lengths.reserve(fileCount);
+ splitInfo->partitionColumns.reserve(fileCount);
+ splitInfo->properties.reserve(fileCount);
+ splitInfo->metadataColumns.reserve(fileCount);
for (const auto& file : fileList) {
// Expect all Partitions share the same index.
splitInfo->partitionIndex = file.partition_index();
std::unordered_map<std::string, std::string> partitionColumnMap;
+ partitionColumnMap.reserve(file.partition_columns_size());
for (const auto& partitionColumn : file.partition_columns()) {
- partitionColumnMap[partitionColumn.key()] = partitionColumn.value();
+ partitionColumnMap.emplace(partitionColumn.key(),
partitionColumn.value());
}
- splitInfo->partitionColumns.emplace_back(partitionColumnMap);
+ splitInfo->partitionColumns.emplace_back(std::move(partitionColumnMap));
Review Comment:
`std::move` is safe here even if `partitionColumnMap` is empty.
`emplace_back` could accept the empty `partitionColumnMap`.
The overhead of `std::move` is very small and check if the
partitionColumnMap isEmpty brings extra overhead.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]