aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/repeated_field.cc
diff options
context:
space:
mode:
authorGravatar kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2009-07-29 01:13:20 +0000
committerGravatar kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2009-07-29 01:13:20 +0000
commit80b1d62bfcea65c59e2160da71dad84b1bd19cef (patch)
tree5423b830c53174fec83a7ea01ff0877e11c1ddb6 /src/google/protobuf/repeated_field.cc
parentd2fd0638c309113ccae3731a58e30419f522269a (diff)
Submit recent changes from internal branch, including "lite mode" for
C++ and Java. See CHANGES.txt for more details.
Diffstat (limited to 'src/google/protobuf/repeated_field.cc')
-rw-r--r--src/google/protobuf/repeated_field.cc49
1 files changed, 35 insertions, 14 deletions
diff --git a/src/google/protobuf/repeated_field.cc b/src/google/protobuf/repeated_field.cc
index 2d5cb0a4..270ef064 100644
--- a/src/google/protobuf/repeated_field.cc
+++ b/src/google/protobuf/repeated_field.cc
@@ -33,30 +33,51 @@
// Sanjay Ghemawat, Jeff Dean, and others.
#include <google/protobuf/repeated_field.h>
+#include <google/protobuf/stubs/common.h>
namespace google {
namespace protobuf {
-
-// HP C++ on Tru64 can't handle the stuff below being defined out-of-line, so
-// on that platform everything is defined in repeated_field.h. On other
-// platforms, we want these to be out-of-line to avoid code bloat.
-#if !defined(__DECCXX) || !defined(__osf__)
-
namespace internal {
-GenericRepeatedField::~GenericRepeatedField() {}
+void RepeatedPtrFieldBase::Swap(RepeatedPtrFieldBase* other) {
+ void** swap_elements = elements_;
+ int swap_current_size = current_size_;
+ int swap_allocated_size = allocated_size_;
+ int swap_total_size = total_size_;
+ // We may not be using initial_space_ but it's not worth checking. Just
+ // copy it anyway.
+ void* swap_initial_space[kInitialSize];
+ memcpy(swap_initial_space, initial_space_, sizeof(initial_space_));
-} // namespace internal
+ elements_ = other->elements_;
+ current_size_ = other->current_size_;
+ allocated_size_ = other->allocated_size_;
+ total_size_ = other->total_size_;
+ memcpy(initial_space_, other->initial_space_, sizeof(initial_space_));
-template <>
-void RepeatedPtrField<string>::Clear() {
- for (int i = 0; i < current_size_; i++) {
- elements_[i]->clear();
+ other->elements_ = swap_elements;
+ other->current_size_ = swap_current_size;
+ other->allocated_size_ = swap_allocated_size;
+ other->total_size_ = swap_total_size;
+ memcpy(other->initial_space_, swap_initial_space, sizeof(swap_initial_space));
+
+ if (elements_ == other->initial_space_) {
+ elements_ = initial_space_;
+ }
+ if (other->elements_ == initial_space_) {
+ other->elements_ = other->initial_space_;
}
- current_size_ = 0;
}
-#endif // !defined(__DECCXX) || !defined(__osf__)
+string* StringTypeHandler::New() {
+ return new string;
+}
+void StringTypeHandler::Delete(string* value) {
+ delete value;
+}
+
+
+} // namespace internal
} // namespace protobuf
} // namespace google