Browse Source

Merge pull request #444 from xfxyjwf/vs2010_fix

Fix two issues on vs2010.
Feng Xiao 10 years ago
parent
commit
dbcfc5e202
2 changed files with 9 additions and 9 deletions
  1. 6 8
      src/google/protobuf/map.h
  2. 3 1
      src/google/protobuf/repeated_field.h

+ 6 - 8
src/google/protobuf/map.h

@@ -176,14 +176,12 @@ class Map {
 
 
     template<class NodeType>
     template<class NodeType>
     void destroy(NodeType* p) {
     void destroy(NodeType* p) {
-      if (arena_ == NULL) p->~NodeType();
+      p->~NodeType();
     }
     }
 #else
 #else
     void construct(pointer p, const_reference t) { new (p) value_type(t); }
     void construct(pointer p, const_reference t) { new (p) value_type(t); }
 
 
-    void destroy(pointer p) {
-      if (arena_ == NULL) p->~value_type();
-    }
+    void destroy(pointer p) { p->~value_type(); }
 #endif
 #endif
 
 
     template <typename X>
     template <typename X>
@@ -201,10 +199,10 @@ class Map {
       return arena_ != other.arena_;
       return arena_ != other.arena_;
     }
     }
 
 
-	// To support Visual Studio 2008
-	size_type max_size() const {
-		return std::numeric_limits<size_type>::max();
-	}
+    // To support Visual Studio 2008
+    size_type max_size() const {
+      return std::numeric_limits<size_type>::max();
+    }
 
 
    private:
    private:
     Arena* arena_;
     Arena* arena_;

+ 3 - 1
src/google/protobuf/repeated_field.h

@@ -1125,7 +1125,9 @@ template <typename Element>
 inline typename RepeatedField<Element>::iterator RepeatedField<Element>::erase(
 inline typename RepeatedField<Element>::iterator RepeatedField<Element>::erase(
     const_iterator first, const_iterator last) {
     const_iterator first, const_iterator last) {
   size_type first_offset = first - cbegin();
   size_type first_offset = first - cbegin();
-  Truncate(std::copy(last, cend(), begin() + first_offset) - cbegin());
+  if (first != last) {
+    Truncate(std::copy(last, cend(), begin() + first_offset) - cbegin());
+  }
   return begin() + first_offset;
   return begin() + first_offset;
 }
 }