Index: base/win/scoped_handle.h |
diff --git a/base/win/scoped_handle.h b/base/win/scoped_handle.h |
index 3378d004f32c96386cf29ef8defeee157ef9e51b..99522e3678591159223fb9ac974218d295c0592b 100644 |
--- a/base/win/scoped_handle.h |
+++ b/base/win/scoped_handle.h |
@@ -49,7 +49,8 @@ class GenericScopedHandle { |
} |
// Move constructor for C++03 move emulation of this type. |
- GenericScopedHandle(RValue& other) : handle_(other.Take()) { |
+ GenericScopedHandle(RValue& other) : handle_(Traits::NullHandle()) { |
+ Set(other.Take()); |
} |
~GenericScopedHandle() { |
@@ -62,9 +63,9 @@ class GenericScopedHandle { |
// Move operator= for C++03 move emulation of this type. |
GenericScopedHandle& operator=(RValue& other) { |
- // Swapping the handles helps to avoid problems while assigning a handle |
- // to itself. It is also cheap and matches base::scoped_ptr behavior. |
- Swap(other); |
+ if (this != static_cast<GenericScopedHandle*>(&other)) { |
jar (doing other things)
2012/08/09 00:00:49
nit: You *might* even get away without a cast... b
alexeypa (please no reviews)
2012/08/09 15:39:03
Done.
|
+ Set(other.Take()); |
+ } |
return *this; |
} |
@@ -97,12 +98,6 @@ class GenericScopedHandle { |
return &handle_; |
} |
- void Swap(GenericScopedHandle& other) { |
- Handle tmp = handle_; |
- handle_ = other.handle_; |
- other.handle_ = tmp; |
- } |
- |
// Transfers ownership away from this object. |
Handle Take() { |
Handle temp = handle_; |