Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: third_party/protobuf/src/google/protobuf/generated_message_util.cc

Issue 2495533002: third_party/protobuf: Update to HEAD (83d681ee2c) (Closed)
Patch Set: Make chrome settings proto generated file a component Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Protocol Buffers - Google's data interchange format 1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved. 2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/ 3 // https://developers.google.com/protocol-buffers/
4 // 4 //
5 // Redistribution and use in source and binary forms, with or without 5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are 6 // modification, are permitted provided that the following conditions are
7 // met: 7 // met:
8 // 8 //
9 // * Redistributions of source code must retain the above copyright 9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer. 10 // notice, this list of conditions and the following disclaimer.
(...skipping 30 matching lines...) Expand all
41 namespace protobuf { 41 namespace protobuf {
42 namespace internal { 42 namespace internal {
43 43
44 double Infinity() { 44 double Infinity() {
45 return std::numeric_limits<double>::infinity(); 45 return std::numeric_limits<double>::infinity();
46 } 46 }
47 double NaN() { 47 double NaN() {
48 return std::numeric_limits<double>::quiet_NaN(); 48 return std::numeric_limits<double>::quiet_NaN();
49 } 49 }
50 50
51 const ::std::string* empty_string_; 51 ExplicitlyConstructed< ::std::string> fixed_address_empty_string;
52 GOOGLE_PROTOBUF_DECLARE_ONCE(empty_string_once_init_); 52 GOOGLE_PROTOBUF_DECLARE_ONCE(empty_string_once_init_);
53 53
54 void DeleteEmptyString() { 54 void DeleteEmptyString() { fixed_address_empty_string.Shutdown(); }
55 delete empty_string_;
56 }
57 55
58 void InitEmptyString() { 56 void InitEmptyString() {
59 empty_string_ = new string; 57 fixed_address_empty_string.DefaultConstruct();
60 OnShutdown(&DeleteEmptyString); 58 OnShutdown(&DeleteEmptyString);
61 } 59 }
62 60
63 const ::std::string& GetEmptyString() { 61 const ::std::string& GetEmptyString() {
64 ::google::protobuf::GoogleOnceInit(&empty_string_once_init_, &InitEmptyString) ; 62 ::google::protobuf::GoogleOnceInit(&empty_string_once_init_, &InitEmptyString) ;
65 return GetEmptyStringAlreadyInited(); 63 return GetEmptyStringAlreadyInited();
66 } 64 }
67 65
68 66
69 int StringSpaceUsedExcludingSelf(const string& str) { 67 int StringSpaceUsedExcludingSelf(const string& str) {
70 const void* start = &str; 68 const void* start = &str;
71 const void* end = &str + 1; 69 const void* end = &str + 1;
72 if (start <= str.data() && str.data() < end) { 70 if (start <= str.data() && str.data() < end) {
73 // The string's data is stored inside the string object itself. 71 // The string's data is stored inside the string object itself.
74 return 0; 72 return 0;
75 } else { 73 } else {
76 return str.capacity(); 74 return str.capacity();
77 } 75 }
78 } 76 }
79 77
80 78
81 79
80 void InitProtobufDefaults() {
81 GetEmptyString();
82 }
83
82 } // namespace internal 84 } // namespace internal
83 } // namespace protobuf 85 } // namespace protobuf
84 } // namespace google 86 } // namespace google
OLDNEW
« no previous file with comments | « third_party/protobuf/src/google/protobuf/generated_message_util.h ('k') | third_party/protobuf/src/google/protobuf/has_bits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698