Skip to content

Commit 3feb6c3

Browse files
authored
Avoid unnecessary copies of PhoneMetadata (#3300)
The PhoneMetadata can be moved into the hashmap avoiding a copy.
1 parent 79ad015 commit 3feb6c3

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

cpp/src/phonenumbers/shortnumberinfo.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ ShortNumberInfo::ShortNumberInfo()
5252
LOG(DFATAL) << "Could not parse compiled-in metadata.";
5353
return;
5454
}
55-
for (const auto& metadata : metadata_collection.metadata()) {
56-
const string& region_code = metadata.id();
57-
region_to_short_metadata_map_->insert(std::make_pair(region_code, metadata));
55+
for (auto& metadata : *(metadata_collection.mutable_metadata())) {
56+
const string region_code = metadata.id();
57+
region_to_short_metadata_map_->emplace(region_code, std::move(metadata));
5858
}
5959
regions_where_emergency_numbers_must_be_exact_->insert("BR");
6060
regions_where_emergency_numbers_must_be_exact_->insert("CL");

0 commit comments

Comments
 (0)