Chromium Code Reviews| Index: base/memory/ref_counted.h |
| diff --git a/base/memory/ref_counted.h b/base/memory/ref_counted.h |
| index 439fda44d1ad4505b6c3666af601450ce45d1a43..c81a1e20bbf3a0646c5854b9aaec77ebe20ffc3b 100644 |
| --- a/base/memory/ref_counted.h |
| +++ b/base/memory/ref_counted.h |
| @@ -260,9 +260,13 @@ class scoped_refptr { |
| // AddRef first so that self assignment should work |
| if (p) |
| p->AddRef(); |
| - if (ptr_ ) |
| - ptr_ ->Release(); |
| - ptr_ = p; |
| + if (ptr_) { |
| + T* old_ptr = ptr_; |
| + ptr_ = p; |
| + old_ptr->Release(); |
| + } else { |
| + ptr_ = p; |
| + } |
|
joth
2011/12/21 16:51:27
Maybe marginally easier to read as..
T* old_ptr =
|
| return *this; |
| } |