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

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

Issue 2885223002: Protobuf: Remove protobuf globals patch (Closed)
Patch Set: typo Created 3 years, 7 months 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_;
52 GOOGLE_PROTOBUF_DECLARE_ONCE(empty_string_once_init_);
53
51 void DeleteEmptyString() { 54 void DeleteEmptyString() {
52 delete cr_empty_string_; 55 delete empty_string_;
53 } 56 }
54 57
55 void InitEmptyString() { 58 void InitEmptyString() {
56 cr_empty_string_ = new string; 59 empty_string_ = new string;
57 OnShutdown(&DeleteEmptyString); 60 OnShutdown(&DeleteEmptyString);
58 } 61 }
59 62
60 const ::std::string& GetEmptyString() { 63 const ::std::string& GetEmptyString() {
61 ::google::protobuf::GoogleOnceInit(&cr_empty_string_once_init_, 64 ::google::protobuf::GoogleOnceInit(&empty_string_once_init_, &InitEmptyString) ;
62 &InitEmptyString);
63 return GetEmptyStringAlreadyInited(); 65 return GetEmptyStringAlreadyInited();
64 } 66 }
65 67
66 68
67 int StringSpaceUsedExcludingSelf(const string& str) { 69 int StringSpaceUsedExcludingSelf(const string& str) {
68 const void* start = &str; 70 const void* start = &str;
69 const void* end = &str + 1; 71 const void* end = &str + 1;
70 if (start <= str.data() && str.data() < end) { 72 if (start <= str.data() && str.data() < end) {
71 // The string's data is stored inside the string object itself. 73 // The string's data is stored inside the string object itself.
72 return 0; 74 return 0;
73 } else { 75 } else {
74 return str.capacity(); 76 return str.capacity();
75 } 77 }
76 } 78 }
77 79
78 80
79 81
80 } // namespace internal 82 } // namespace internal
81 } // namespace protobuf 83 } // namespace protobuf
82 } // namespace google 84 } // 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/globals.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698