pitrou commented on code in PR #50970:
URL: https://github.com/apache/arrow/pull/50970#discussion_r3845010741
##########
cpp/src/arrow/type.cc:
##########
@@ -1333,8 +1333,10 @@ namespace {
std::unordered_multimap<std::string_view, int> CreateNameToIndexMap(
const FieldVector& fields) {
std::unordered_multimap<std::string_view, int> name_to_index;
+ name_to_index.reserve(fields.size());
for (size_t i = 0; i < fields.size(); ++i) {
- name_to_index.emplace(fields[i]->name(), static_cast<int>(i));
+ const std::string_view name = fields[i]->name();
+ name_to_index.emplace_hint(name_to_index.find(name), name,
static_cast<int>(i));
Review Comment:
Can you add a comment explaining the motivation for this construct?
##########
cpp/src/arrow/type.cc:
##########
@@ -2294,7 +2296,7 @@ Schema::Schema(FieldVector fields, std::shared_ptr<const
KeyValueMetadata> metad
impl_(new Impl(std::move(fields), Endianness::Native,
std::move(metadata))) {}
Schema::Schema(const Schema& schema)
- : detail::Fingerprintable(), impl_(new Impl(*schema.impl_)) {}
+ : Schema(schema.impl_->fields_, schema.impl_->endianness_,
schema.impl_->metadata_) {}
Review Comment:
Why not just copy the `Impl` object instead of recreating the name-to-index
map?
--
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]