diff options
author | Feng Xiao <xiaofeng@google.com> | 2015-08-28 14:09:00 -0700 |
---|---|---|
committer | Feng Xiao <xiaofeng@google.com> | 2015-08-28 14:09:00 -0700 |
commit | f0640b5a046522d7ffbab02b87a8ce9a654f79d1 (patch) | |
tree | 0e42a47ac764537c1be76c29f5d9b04ad392113a | |
parent | 69ac02a216591d437dfa1dbca2931cffe9790df9 (diff) | |
parent | b913cbd3073826ea113efe917d4d3ce71b92ab2d (diff) | |
download | protobuf-f0640b5a046522d7ffbab02b87a8ce9a654f79d1.tar.gz protobuf-f0640b5a046522d7ffbab02b87a8ce9a654f79d1.tar.bz2 protobuf-f0640b5a046522d7ffbab02b87a8ce9a654f79d1.zip |
Merge pull request #770 from pkasting/string_space
Move StringSpaceUsedIncludingSelf to lite library.
-rw-r--r-- | src/google/protobuf/generated_message_reflection.cc | 12 | ||||
-rw-r--r-- | src/google/protobuf/generated_message_util.cc | 12 | ||||
-rw-r--r-- | src/google/protobuf/generated_message_util.h | 6 | ||||
-rw-r--r-- | src/google/protobuf/repeated_field.h | 3 |
4 files changed, 14 insertions, 19 deletions
diff --git a/src/google/protobuf/generated_message_reflection.cc b/src/google/protobuf/generated_message_reflection.cc index 412c48a1..0b01e73a 100644 --- a/src/google/protobuf/generated_message_reflection.cc +++ b/src/google/protobuf/generated_message_reflection.cc @@ -57,18 +57,6 @@ bool IsMapFieldInApi(const FieldDescriptor* field) { } } // anonymous namespace -int StringSpaceUsedExcludingSelf(const string& str) { - const void* start = &str; - const void* end = &str + 1; - - if (start <= str.data() && str.data() < end) { - // The string's data is stored inside the string object itself. - return 0; - } else { - return str.capacity(); - } -} - bool ParseNamedEnum(const EnumDescriptor* descriptor, const string& name, int* value) { diff --git a/src/google/protobuf/generated_message_util.cc b/src/google/protobuf/generated_message_util.cc index 53cae8b5..afaca2ee 100644 --- a/src/google/protobuf/generated_message_util.cc +++ b/src/google/protobuf/generated_message_util.cc @@ -60,6 +60,18 @@ void InitEmptyString() { OnShutdown(&DeleteEmptyString); } +int StringSpaceUsedExcludingSelf(const string& str) { + const void* start = &str; + const void* end = &str + 1; + + if (start <= str.data() && str.data() < end) { + // The string's data is stored inside the string object itself. + return 0; + } else { + return str.capacity(); + } +} + } // namespace internal } // namespace protobuf diff --git a/src/google/protobuf/generated_message_util.h b/src/google/protobuf/generated_message_util.h index 6357e27d..78c8d7ff 100644 --- a/src/google/protobuf/generated_message_util.h +++ b/src/google/protobuf/generated_message_util.h @@ -89,12 +89,6 @@ LIBPROTOBUF_EXPORT inline const ::std::string& GetEmptyString() { return GetEmptyStringAlreadyInited(); } -// Defined in generated_message_reflection.cc -- not actually part of the lite -// library. -// -// TODO(jasonh): The various callers get this declaration from a variety of -// places: probably in most cases repeated_field.h. Clean these up so they all -// get the declaration from this file. LIBPROTOBUF_EXPORT int StringSpaceUsedExcludingSelf(const string& str); diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h index 9c84ed98..2ba5dfd5 100644 --- a/src/google/protobuf/repeated_field.h +++ b/src/google/protobuf/repeated_field.h @@ -647,7 +647,8 @@ inline const Message& GenericTypeHandler<Message>::default_instance() { // StringTypeHandler is exported. So, we factor out StringTypeHandlerBase, // export that, then make StringTypeHandler be a subclass which is NOT // exported. -// TODO(kenton): There has to be a better way. +// TODO(kenton): Now that StringSpaceUsedExcludingSelf() is in the lite
+// library, this can be cleaned up. class LIBPROTOBUF_EXPORT StringTypeHandlerBase { public: typedef string Type; |