Commit 5a6483ff authored by clemensh's avatar clemensh Committed by Commit bot

[inspector] Avoid unneeded heap allocations

v8::Global is movable, so no need to heap-allocate them.

R=yangguo@chromium.org, kozyatinskiy@chromium.org

Review-Url: https://codereview.chromium.org/2537433002
Cr-Commit-Position: refs/heads/master@{#41379}
parent 8037e98e
......@@ -44,8 +44,8 @@ int InjectedScriptNative::bind(v8::Local<v8::Value> value,
const String16& groupName) {
if (m_lastBoundObjectId <= 0) m_lastBoundObjectId = 1;
int id = m_lastBoundObjectId++;
m_idToWrappedObject[id] = std::unique_ptr<v8::Global<v8::Value>>(
new v8::Global<v8::Value>(m_isolate, value));
m_idToWrappedObject.insert(
std::make_pair(id, v8::Global<v8::Value>(m_isolate, value)));
addObjectToGroup(id, groupName);
return id;
}
......@@ -57,7 +57,7 @@ void InjectedScriptNative::unbind(int id) {
v8::Local<v8::Value> InjectedScriptNative::objectForId(int id) {
auto iter = m_idToWrappedObject.find(id);
return iter != m_idToWrappedObject.end() ? iter->second->Get(m_isolate)
return iter != m_idToWrappedObject.end() ? iter->second.Get(m_isolate)
: v8::Local<v8::Value>();
}
......
......@@ -34,8 +34,7 @@ class InjectedScriptNative final {
int m_lastBoundObjectId;
v8::Isolate* m_isolate;
protocol::HashMap<int, std::unique_ptr<v8::Global<v8::Value>>>
m_idToWrappedObject;
protocol::HashMap<int, v8::Global<v8::Value>> m_idToWrappedObject;
typedef protocol::HashMap<int, String16> IdToObjectGroupName;
IdToObjectGroupName m_idToObjectGroupName;
typedef protocol::HashMap<String16, std::vector<int>> NameToObjectGroup;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment