diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-29 22:42:22 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-29 22:42:22 +0000 |
commit | 345242866b1b6ae2f73334c24f6a8775958f9f95 (patch) | |
tree | e554a5fa9abe4be50225103cbba2d097c2c6c01d /base/memory | |
parent | 09c4fc35fc1ffec42bbd8f4cb3effe4f421499d7 (diff) | |
download | chromium_src-345242866b1b6ae2f73334c24f6a8775958f9f95.zip chromium_src-345242866b1b6ae2f73334c24f6a8775958f9f95.tar.gz chromium_src-345242866b1b6ae2f73334c24f6a8775958f9f95.tar.bz2 |
Remove the free_ member of scoped_ptr_malloc.
Conceptually, the function to call is known at compile time.
There is no reason to save it into a static variable. It turns out
doing causes the compiler to emit a static initializer to track whether
free_ has been initialized.
This change removes static initializers from eight .o files on my local
Release build.
BUG=87171
Review URL: http://codereview.chromium.org/7795008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98718 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/memory')
-rw-r--r-- | base/memory/scoped_ptr.h | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/base/memory/scoped_ptr.h b/base/memory/scoped_ptr.h index 1067d42..5ac6846 100644 --- a/base/memory/scoped_ptr.h +++ b/base/memory/scoped_ptr.h @@ -285,7 +285,7 @@ class scoped_ptr_malloc { // Destructor. If there is a C object, call the Free functor. ~scoped_ptr_malloc() { - free_(ptr_); + reset(); } // Reset. Calls the Free functor on the current owned object, if any. @@ -293,7 +293,8 @@ class scoped_ptr_malloc { // this->reset(this->get()) works. void reset(C* p = NULL) { if (ptr_ != p) { - free_(ptr_); + FreeProc free_proc; + free_proc(ptr_); ptr_ = p; } } @@ -355,16 +356,11 @@ class scoped_ptr_malloc { template <class C2, class GP> bool operator!=(scoped_ptr_malloc<C2, GP> const& p) const; - static FreeProc const free_; - // Disallow evil constructors scoped_ptr_malloc(const scoped_ptr_malloc&); void operator=(const scoped_ptr_malloc&); }; -template<class C, class FP> -FP const scoped_ptr_malloc<C, FP>::free_ = FP(); - template<class C, class FP> inline void swap(scoped_ptr_malloc<C, FP>& a, scoped_ptr_malloc<C, FP>& b) { a.swap(b); |