From 5a76e633ea9b5adb215e93fdc11e1c0c08b3fc74 Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Thu, 17 Nov 2016 16:48:38 -0800 Subject: Integrated internal changes from Google --- src/google/protobuf/descriptor_database.cc | 47 ++++++++++++++++-------------- 1 file changed, 25 insertions(+), 22 deletions(-) (limited to 'src/google/protobuf/descriptor_database.cc') diff --git a/src/google/protobuf/descriptor_database.cc b/src/google/protobuf/descriptor_database.cc index 2117c020..57ae960f 100644 --- a/src/google/protobuf/descriptor_database.cc +++ b/src/google/protobuf/descriptor_database.cc @@ -97,11 +97,12 @@ bool SimpleDescriptorDatabase::DescriptorIndex::AddSymbol( // Try to look up the symbol to make sure a super-symbol doesn't already // exist. - typename map::iterator iter = FindLastLessOrEqual(name); + typename std::map::iterator iter = FindLastLessOrEqual(name); if (iter == by_symbol_.end()) { // Apparently the map is currently empty. Just insert and be done with it. - by_symbol_.insert(typename map::value_type(name, value)); + by_symbol_.insert( + typename std::map::value_type(name, value)); return true; } @@ -128,7 +129,8 @@ bool SimpleDescriptorDatabase::DescriptorIndex::AddSymbol( // Insert the new symbol using the iterator as a hint, the new entry will // appear immediately before the one the iterator is pointing at. - by_symbol_.insert(iter, typename map::value_type(name, value)); + by_symbol_.insert(iter, + typename std::map::value_type(name, value)); return true; } @@ -179,7 +181,7 @@ Value SimpleDescriptorDatabase::DescriptorIndex::FindFile( template Value SimpleDescriptorDatabase::DescriptorIndex::FindSymbol( const string& name) { - typename map::iterator iter = FindLastLessOrEqual(name); + typename std::map::iterator iter = FindLastLessOrEqual(name); return (iter != by_symbol_.end() && IsSubSymbol(iter->first, name)) ? iter->second : Value(); @@ -196,8 +198,8 @@ Value SimpleDescriptorDatabase::DescriptorIndex::FindExtension( template bool SimpleDescriptorDatabase::DescriptorIndex::FindAllExtensionNumbers( const string& containing_type, - vector* output) { - typename map, Value>::const_iterator it = + std::vector* output) { + typename std::map, Value>::const_iterator it = by_extension_.lower_bound(std::make_pair(containing_type, 0)); bool success = false; @@ -217,7 +219,8 @@ SimpleDescriptorDatabase::DescriptorIndex::FindLastLessOrEqual( // Find the last key in the map which sorts less than or equal to the // symbol name. Since upper_bound() returns the *first* key that sorts // *greater* than the input, we want the element immediately before that. - typename map::iterator iter = by_symbol_.upper_bound(name); + typename std::map::iterator iter = + by_symbol_.upper_bound(name); if (iter != by_symbol_.begin()) --iter; return iter; } @@ -284,7 +287,7 @@ bool SimpleDescriptorDatabase::FindFileContainingExtension( bool SimpleDescriptorDatabase::FindAllExtensionNumbers( const string& extendee_type, - vector* output) { + std::vector* output) { return index_.FindAllExtensionNumbers(extendee_type, output); } @@ -340,7 +343,7 @@ bool EncodedDescriptorDatabase::FindFileContainingSymbol( bool EncodedDescriptorDatabase::FindNameOfFileContainingSymbol( const string& symbol_name, string* output) { - pair encoded_file = index_.FindSymbol(symbol_name); + std::pair encoded_file = index_.FindSymbol(symbol_name); if (encoded_file.first == NULL) return false; // Optimization: The name should be the first field in the encoded message. @@ -352,7 +355,7 @@ bool EncodedDescriptorDatabase::FindNameOfFileContainingSymbol( FileDescriptorProto::kNameFieldNumber, internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED); - if (input.ReadTag() == kNameTag) { + if (input.ReadTagNoLastTag() == kNameTag) { // Success! return internal::WireFormatLite::ReadString(&input, output); } else { @@ -376,12 +379,12 @@ bool EncodedDescriptorDatabase::FindFileContainingExtension( bool EncodedDescriptorDatabase::FindAllExtensionNumbers( const string& extendee_type, - vector* output) { + std::vector* output) { return index_.FindAllExtensionNumbers(extendee_type, output); } bool EncodedDescriptorDatabase::MaybeParse( - pair encoded_file, + std::pair encoded_file, FileDescriptorProto* output) { if (encoded_file.first == NULL) return false; return output->ParseFromArray(encoded_file.first, encoded_file.second); @@ -431,11 +434,11 @@ bool DescriptorPoolDatabase::FindFileContainingExtension( bool DescriptorPoolDatabase::FindAllExtensionNumbers( const string& extendee_type, - vector* output) { + std::vector* output) { const Descriptor* extendee = pool_.FindMessageTypeByName(extendee_type); if (extendee == NULL) return false; - vector extensions; + std::vector extensions; pool_.FindAllExtensions(extendee, &extensions); for (int i = 0; i < extensions.size(); ++i) { @@ -454,7 +457,7 @@ MergedDescriptorDatabase::MergedDescriptorDatabase( sources_.push_back(source2); } MergedDescriptorDatabase::MergedDescriptorDatabase( - const vector& sources) + const std::vector& sources) : sources_(sources) {} MergedDescriptorDatabase::~MergedDescriptorDatabase() {} @@ -517,23 +520,23 @@ bool MergedDescriptorDatabase::FindFileContainingExtension( bool MergedDescriptorDatabase::FindAllExtensionNumbers( const string& extendee_type, - vector* output) { - set merged_results; - vector results; + std::vector* output) { + std::set merged_results; + std::vector results; bool success = false; for (int i = 0; i < sources_.size(); i++) { if (sources_[i]->FindAllExtensionNumbers(extendee_type, &results)) { - std::copy( - results.begin(), results.end(), - insert_iterator >(merged_results, merged_results.begin())); + std::copy(results.begin(), results.end(), + std::insert_iterator >(merged_results, + merged_results.begin())); success = true; } results.clear(); } std::copy(merged_results.begin(), merged_results.end(), - insert_iterator >(*output, output->end())); + std::insert_iterator >(*output, output->end())); return success; } -- cgit v1.2.3