From ef9499cb44f58904d55997a9f934f1e477bcba18 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Tue, 14 May 2019 16:14:22 -0700 Subject: Migrate std::unordered_map -> absl::flat_hash_map. --- upbc/generator.cc | 5 ++--- upbc/message_layout.h | 10 +++++----- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'upbc') diff --git a/upbc/generator.cc b/upbc/generator.cc index 5843597..1337e28 100644 --- a/upbc/generator.cc +++ b/upbc/generator.cc @@ -1,8 +1,7 @@ -#include -#include #include +#include "absl/container/flat_hash_map.h" #include "absl/strings/ascii.h" #include "absl/strings/str_replace.h" #include "absl/strings/substitute.h" @@ -594,7 +593,7 @@ void WriteSource(const protobuf::FileDescriptor* file, Output& output) { std::string fields_array_ref = "NULL"; std::string submsgs_array_ref = "NULL"; std::string oneofs_array_ref = "NULL"; - std::unordered_map submsg_indexes; + absl::flat_hash_map submsg_indexes; MessageLayout layout(message); std::vector sorted_submsgs = SortedSubmessages(message); diff --git a/upbc/message_layout.h b/upbc/message_layout.h index a4cb289..c2446a0 100644 --- a/upbc/message_layout.h +++ b/upbc/message_layout.h @@ -2,8 +2,8 @@ #ifndef UPBC_MESSAGE_LAYOUT_H #define UPBC_MESSAGE_LAYOUT_H -#include #include "absl/base/macros.h" +#include "absl/container/flat_hash_map.h" #include "google/protobuf/descriptor.h" namespace upbc { @@ -70,7 +70,7 @@ class MessageLayout { Size Place(SizeAndAlign size_and_align); template - static V GetMapValue(const std::unordered_map& map, K key) { + static V GetMapValue(const absl::flat_hash_map& map, K key) { auto iter = map.find(key); if (iter == map.end()) { fprintf(stderr, "No value for field.\n"); @@ -92,11 +92,11 @@ class MessageLayout { static int64_t FieldLayoutRank( const google::protobuf::FieldDescriptor* field); - std::unordered_map + absl::flat_hash_map field_offsets_; - std::unordered_map + absl::flat_hash_map hasbit_indexes_; - std::unordered_map + absl::flat_hash_map oneof_case_offsets_; Size maxalign_; Size size_; -- cgit v1.2.3