diff options
author | tzik <tzik@chromium.org> | 2015-11-24 19:16:48 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-25 03:17:45 +0000 |
commit | 8f7af292172d43eba1b3ea11ffecf4f8862cf0b3 (patch) | |
tree | 310d4426edf42fbd1ff1fdd9485f72b63de0849f /extensions/renderer | |
parent | 5748ab7a49ce7f1b9a5008a242d52977449553cb (diff) | |
download | chromium_src-8f7af292172d43eba1b3ea11ffecf4f8862cf0b3.zip chromium_src-8f7af292172d43eba1b3ea11ffecf4f8862cf0b3.tar.gz chromium_src-8f7af292172d43eba1b3ea11ffecf4f8862cf0b3.tar.bz2 |
Use scoped_ptr in extensions::ModuleSystem
This CL replaces linked_ptr with scoped_ptr in ModuleSystem.
These linked_ptrs are used in a moderately-hot path on the loading
phase, and the replacement saves small amount of time (~100μs) per
frame from the first paint critical path.
BUG=540988
Review URL: https://codereview.chromium.org/1471843003
Cr-Commit-Position: refs/heads/master@{#361540}
Diffstat (limited to 'extensions/renderer')
-rw-r--r-- | extensions/renderer/module_system.cc | 5 | ||||
-rw-r--r-- | extensions/renderer/module_system.h | 5 |
2 files changed, 4 insertions, 6 deletions
diff --git a/extensions/renderer/module_system.cc b/extensions/renderer/module_system.cc index e84f0e0..923418a 100644 --- a/extensions/renderer/module_system.cc +++ b/extensions/renderer/module_system.cc @@ -338,8 +338,7 @@ void ModuleSystem::RegisterNativeHandler( const std::string& name, scoped_ptr<NativeHandler> native_handler) { ClobberExistingNativeHandler(name); - native_handler_map_[name] = - linked_ptr<NativeHandler>(native_handler.release()); + native_handler_map_[name] = std::move(native_handler); } void ModuleSystem::OverrideNativeHandlerForTest(const std::string& name) { @@ -747,7 +746,7 @@ void ModuleSystem::OnModuleLoaded( void ModuleSystem::ClobberExistingNativeHandler(const std::string& name) { NativeHandlerMap::iterator existing_handler = native_handler_map_.find(name); if (existing_handler != native_handler_map_.end()) { - clobbered_native_handlers_.push_back(existing_handler->second); + clobbered_native_handlers_.push_back(std::move(existing_handler->second)); native_handler_map_.erase(existing_handler); } } diff --git a/extensions/renderer/module_system.h b/extensions/renderer/module_system.h index b8d4104..e8c2601 100644 --- a/extensions/renderer/module_system.h +++ b/extensions/renderer/module_system.h @@ -11,7 +11,6 @@ #include <vector> #include "base/compiler_specific.h" -#include "base/memory/linked_ptr.h" #include "base/memory/scoped_ptr.h" #include "extensions/renderer/native_handler.h" #include "extensions/renderer/object_backed_native_handler.h" @@ -151,7 +150,7 @@ class ModuleSystem : public ObjectBackedNativeHandler, void Invalidate() override; private: - typedef std::map<std::string, linked_ptr<NativeHandler> > NativeHandlerMap; + typedef std::map<std::string, scoped_ptr<NativeHandler>> NativeHandlerMap; // Retrieves the lazily defined field specified by |property|. static void LazyFieldGetter(v8::Local<v8::Name> property, @@ -240,7 +239,7 @@ class ModuleSystem : public ObjectBackedNativeHandler, // registering a NativeHandler when one was already registered with the same // name, or due to OverrideNativeHandlerForTest. This is needed so that they // can be later Invalidated. It should only happen in tests. - std::vector<linked_ptr<NativeHandler>> clobbered_native_handlers_; + std::vector<scoped_ptr<NativeHandler>> clobbered_native_handlers_; base::WeakPtrFactory<ModuleSystem> weak_factory_; |