88// Implements the DescriptorPool, which collects all descriptors.
99
1010#include < string>
11- #include < unordered_map>
1211#include < utility>
1312#include < vector>
1413
1918#include " absl/container/flat_hash_map.h"
2019#include " absl/status/status.h"
2120#include " absl/strings/str_cat.h"
22- #include " absl/strings/str_replace.h"
2321#include " absl/strings/string_view.h"
2422#include " google/protobuf/pyext/descriptor.h"
2523#include " google/protobuf/pyext/descriptor_database.h"
@@ -45,7 +43,7 @@ namespace python {
4543
4644// A map to cache Python Pools per C++ pointer.
4745// Pointers are not owned here, and belong to the PyDescriptorPool.
48- static std::unordered_map <const DescriptorPool*, PyDescriptorPool*>*
46+ static absl::flat_hash_map <const DescriptorPool*, PyDescriptorPool*>*
4947 descriptor_pool_map;
5048
5149namespace cdescriptor_pool {
@@ -684,7 +682,7 @@ bool InitDescriptorPool() {
684682 // generated_pool() contains all messages already linked in C++ libraries, and
685683 // is used as underlay.
686684 descriptor_pool_map =
687- new std::unordered_map <const DescriptorPool*, PyDescriptorPool*>;
685+ new absl::flat_hash_map <const DescriptorPool*, PyDescriptorPool*>;
688686 python_generated_pool = cdescriptor_pool::PyDescriptorPool_NewWithUnderlay (
689687 DescriptorPool::generated_pool ());
690688 if (python_generated_pool == nullptr ) {
@@ -714,8 +712,7 @@ PyDescriptorPool* GetDescriptorPool_FromPool(const DescriptorPool* pool) {
714712 pool == DescriptorPool::generated_pool ()) {
715713 return python_generated_pool;
716714 }
717- std::unordered_map<const DescriptorPool*, PyDescriptorPool*>::iterator it =
718- descriptor_pool_map->find (pool);
715+ auto it = descriptor_pool_map->find (pool);
719716 if (it == descriptor_pool_map->end ()) {
720717 PyErr_SetString (PyExc_KeyError, " Unknown descriptor pool" );
721718 return nullptr ;
0 commit comments