diff --git a/CHANGES.txt b/CHANGES.txt index 9593319d0e..8cd58aa13b 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -20,6 +20,8 @@ * Avoid inlining some large heavily duplicated routines in repeated_ptr_field.h * Add ReflectiveProtoHook to Reflection. * Turns on table-driven parser for reflection based objects. + * Save code space by avoiding inlining of large-in-aggregate code-space MessageLite::~MessageLite destructor. + * Undefine the macro `linux` when compiling protobuf Kotlin diff --git a/python/google/protobuf/pyext/descriptor_containers.cc b/python/google/protobuf/pyext/descriptor_containers.cc index 8c038e9dc9..f38fdc74e5 100644 --- a/python/google/protobuf/pyext/descriptor_containers.cc +++ b/python/google/protobuf/pyext/descriptor_containers.cc @@ -54,6 +54,8 @@ // This inclusion must appear before all the others. #include +#include + #include "google/protobuf/pyext/descriptor_containers.h" // clang-format on diff --git a/python/google/protobuf/pyext/descriptor_database.cc b/python/google/protobuf/pyext/descriptor_database.cc index 7ef94b3860..e547306d51 100644 --- a/python/google/protobuf/pyext/descriptor_database.cc +++ b/python/google/protobuf/pyext/descriptor_database.cc @@ -34,6 +34,8 @@ #include "google/protobuf/pyext/descriptor_database.h" #include +#include +#include #include "google/protobuf/stubs/logging.h" #include "google/protobuf/stubs/common.h" diff --git a/python/google/protobuf/pyext/descriptor_database.h b/python/google/protobuf/pyext/descriptor_database.h index 598466e981..108a8583b3 100644 --- a/python/google/protobuf/pyext/descriptor_database.h +++ b/python/google/protobuf/pyext/descriptor_database.h @@ -34,6 +34,9 @@ #define PY_SSIZE_T_CLEAN #include +#include +#include + #include "google/protobuf/descriptor_database.h" namespace google { diff --git a/python/google/protobuf/pyext/descriptor_pool.cc b/python/google/protobuf/pyext/descriptor_pool.cc index 0f25ed3539..db14ae6624 100644 --- a/python/google/protobuf/pyext/descriptor_pool.cc +++ b/python/google/protobuf/pyext/descriptor_pool.cc @@ -30,7 +30,10 @@ // Implements the DescriptorPool, which collects all descriptors. +#include #include +#include +#include #define PY_SSIZE_T_CLEAN #include diff --git a/python/google/protobuf/pyext/extension_dict.cc b/python/google/protobuf/pyext/extension_dict.cc index d03ad87d23..806af4f865 100644 --- a/python/google/protobuf/pyext/extension_dict.cc +++ b/python/google/protobuf/pyext/extension_dict.cc @@ -35,6 +35,7 @@ #include #include +#include #include "google/protobuf/stubs/logging.h" #include "google/protobuf/stubs/common.h" diff --git a/python/google/protobuf/pyext/map_container.cc b/python/google/protobuf/pyext/map_container.cc index e5496105bb..76c4d888a2 100644 --- a/python/google/protobuf/pyext/map_container.cc +++ b/python/google/protobuf/pyext/map_container.cc @@ -34,6 +34,7 @@ #include #include +#include #include "google/protobuf/stubs/logging.h" #include "google/protobuf/stubs/common.h" diff --git a/python/google/protobuf/pyext/message.cc b/python/google/protobuf/pyext/message.cc index 13495851f5..7990e95ac1 100644 --- a/python/google/protobuf/pyext/message.cc +++ b/python/google/protobuf/pyext/message.cc @@ -38,6 +38,7 @@ #include #include #include +#include #include #include diff --git a/python/google/protobuf/pyext/message_factory.cc b/python/google/protobuf/pyext/message_factory.cc index bcbd7d8d7b..27aa5e4417 100644 --- a/python/google/protobuf/pyext/message_factory.cc +++ b/python/google/protobuf/pyext/message_factory.cc @@ -29,6 +29,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include +#include #define PY_SSIZE_T_CLEAN #include diff --git a/python/google/protobuf/pyext/repeated_scalar_container.cc b/python/google/protobuf/pyext/repeated_scalar_container.cc index 1a39468e96..57746dcf77 100644 --- a/python/google/protobuf/pyext/repeated_scalar_container.cc +++ b/python/google/protobuf/pyext/repeated_scalar_container.cc @@ -35,6 +35,7 @@ #include #include +#include #include "google/protobuf/stubs/common.h" #include "google/protobuf/stubs/logging.h" diff --git a/src/google/protobuf/compiler/cpp/helpers.h b/src/google/protobuf/compiler/cpp/helpers.h index 55fe178cdc..19120e313c 100644 --- a/src/google/protobuf/compiler/cpp/helpers.h +++ b/src/google/protobuf/compiler/cpp/helpers.h @@ -220,7 +220,7 @@ inline const Descriptor* FieldScope(const FieldDescriptor* field) { std::string FieldMessageTypeName(const FieldDescriptor* field, const Options& options); -// Get the C++ type name for a primitive type (e.g. "double", "::google::protobuf::int32", etc.). +// Get the C++ type name for a primitive type (e.g. "double", "::int32", etc.). const char* PrimitiveTypeName(FieldDescriptor::CppType type); std::string PrimitiveTypeName(const Options& options, FieldDescriptor::CppType type); diff --git a/src/google/protobuf/io/printer.cc b/src/google/protobuf/io/printer.cc index 0b8e053ea2..c4d184733b 100644 --- a/src/google/protobuf/io/printer.cc +++ b/src/google/protobuf/io/printer.cc @@ -169,7 +169,13 @@ void Printer::Emit( absl::flat_hash_map>> - map = vars; + map; + map.reserve(vars.size()); + for (auto& var : vars) { + auto result = map.insert(var); + GOOGLE_CHECK(result.second) << "repeated variable in Emit() call: \"" << var.first + << "\""; + } var_lookups_.emplace_back([&map](absl::string_view var) -> LookupResult { auto it = map.find(var); diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc index bbfc299d19..ac4b2b9ed3 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc @@ -875,6 +875,13 @@ #undef PACKAGE #endif +// linux is a legacy MACRO defined in most popular C++ standards. +#ifdef linux +#pragma push_macro("linux") +#undef linux +#define PROTOBUF_DID_UNDEF_LINUX +#endif + // Windows declares several inconvenient macro names. We #undef them and then // restore them in port_undef.inc. #ifdef _WIN32 diff --git a/src/google/protobuf/port_undef.inc b/src/google/protobuf/port_undef.inc index 4dd6586811..e991502faa 100644 --- a/src/google/protobuf/port_undef.inc +++ b/src/google/protobuf/port_undef.inc @@ -121,12 +121,17 @@ #undef PROTOBUF_FUTURE_FINAL +// Restore macros that may have been #undef'd in port_def.inc. + #ifdef PROTOBUF_DID_UNDEF_PACKAGE #pragma pop_macro("PACKAGE") #undef PROTOBUF_DID_UNDEF_PACKAGE #endif -// Restore macro that may have been #undef'd in port_def.inc. +#ifdef PROTOBUF_DID_UNDEF_LINUX +#pragma pop_macro("linux") +#endif + #ifdef _WIN32 #pragma pop_macro("CREATE_NEW") #pragma pop_macro("DELETE") diff --git a/src/google/protobuf/text_format.cc b/src/google/protobuf/text_format.cc index 8633e88699..cf2afa2ffb 100644 --- a/src/google/protobuf/text_format.cc +++ b/src/google/protobuf/text_format.cc @@ -53,6 +53,7 @@ #include "google/protobuf/stubs/strutil.h" #include "absl/strings/ascii.h" #include "absl/strings/escaping.h" +#include "absl/strings/numbers.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_join.h" #include "absl/strings/string_view.h"