perf: optimize data structures in context_bridge::ObjectCache (#27639)
* Use std::forward_list instead of base::LinkedList for better perf, more consistent memory management. Better than std::list because we don't need the double-linked-list behavior of std::list * Use std::unordered_map instead of std::map for the v8 hash table
This commit is contained in:
parent
1bbfa934f0
commit
09870d97b5
2 changed files with 5 additions and 28 deletions
|
@ -5,7 +5,7 @@
|
|||
#ifndef SHELL_RENDERER_API_CONTEXT_BRIDGE_OBJECT_CACHE_H_
|
||||
#define SHELL_RENDERER_API_CONTEXT_BRIDGE_OBJECT_CACHE_H_
|
||||
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
|
||||
#include "base/containers/linked_list.h"
|
||||
|
@ -22,13 +22,6 @@ namespace context_bridge {
|
|||
|
||||
using ObjectCachePair = std::pair<v8::Local<v8::Value>, v8::Local<v8::Value>>;
|
||||
|
||||
struct ObjectCachePairNode : public base::LinkNode<ObjectCachePairNode> {
|
||||
explicit ObjectCachePairNode(ObjectCachePair&& pair);
|
||||
~ObjectCachePairNode();
|
||||
|
||||
ObjectCachePair pair;
|
||||
};
|
||||
|
||||
class ObjectCache final {
|
||||
public:
|
||||
ObjectCache();
|
||||
|
@ -41,7 +34,7 @@ class ObjectCache final {
|
|||
|
||||
private:
|
||||
// object_identity ==> [from_value, proxy_value]
|
||||
std::map<int, base::LinkedList<ObjectCachePairNode>> proxy_map_;
|
||||
std::unordered_map<int, std::forward_list<ObjectCachePair>> proxy_map_;
|
||||
};
|
||||
|
||||
} // namespace context_bridge
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue