Skip to content

Commit

Permalink
Do not expose internal DS (iterator) of AreaCodeMaps (google#2716)
Browse files Browse the repository at this point in the history
  • Loading branch information
katbohm authored Jan 10, 2022
1 parent 3285ff2 commit f1c748d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
13 changes: 5 additions & 8 deletions cpp/src/phonenumbers/geocoding/phonenumber_offline_geocoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,12 @@ const AreaCodeMap* PhoneNumberOfflineGeocoder::GetPhonePrefixDescriptions(
}
AreaCodeMaps::const_iterator it = available_maps_.find(filename);
if (it == available_maps_.end()) {
it = LoadAreaCodeMapFromFile(filename);
if (it == available_maps_.end()) {
return NULL;
}
return LoadAreaCodeMapFromFile(filename);
}
return it->second;
}

PhoneNumberOfflineGeocoder::AreaCodeMaps::const_iterator
PhoneNumberOfflineGeocoder::LoadAreaCodeMapFromFile(
const AreaCodeMap* PhoneNumberOfflineGeocoder::LoadAreaCodeMapFromFile(
const string& filename) const {
const char** const prefix_language_code_pairs_end =
prefix_language_code_pairs_ + prefix_language_code_pairs_size_;
Expand All @@ -114,9 +110,10 @@ PhoneNumberOfflineGeocoder::LoadAreaCodeMapFromFile(
AreaCodeMap* const m = new AreaCodeMap();
m->ReadAreaCodeMap(get_prefix_descriptions_(
prefix_language_code_pair - prefix_language_code_pairs_));
return available_maps_.insert(AreaCodeMaps::value_type(filename, m)).first;
return available_maps_.insert(AreaCodeMaps::value_type(filename, m))
.first->second;
}
return available_maps_.end();
return NULL;
}

string PhoneNumberOfflineGeocoder::GetCountryNameForNumber(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class PhoneNumberOfflineGeocoder {
int prefix_language_code_pairs_size,
prefix_descriptions_getter get_prefix_descriptions);

AreaCodeMaps::const_iterator LoadAreaCodeMapFromFile(
const AreaCodeMap* LoadAreaCodeMapFromFile(
const string& filename) const ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_);

const AreaCodeMap* GetPhonePrefixDescriptions(
Expand Down

0 comments on commit f1c748d

Please sign in to comment.