From 85f8f23a2301628e0f50a4ee19e8da2df8c1665a Mon Sep 17 00:00:00 2001 From: Moonchild Date: Fri, 17 Jan 2025 15:52:11 +0100 Subject: [PATCH] Issue #2678 - Make QIing to a few often-used CCed classes faster. QIing to CC interfaces is a hot path for a few widely-used classes. Presumably there are many of these objects being created and destroyed. By making these classes check first for the CC interfaces directly, rather than going up the inheritance chain, the resulting overhead is reduced. --- dom/base/nsStyledElement.cpp | 8 +++++--- dom/base/nsTextNode.cpp | 9 +++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/dom/base/nsStyledElement.cpp b/dom/base/nsStyledElement.cpp index 607926a484..4fd423acc7 100644 --- a/dom/base/nsStyledElement.cpp +++ b/dom/base/nsStyledElement.cpp @@ -25,9 +25,11 @@ using namespace mozilla; using namespace mozilla::dom; -NS_IMPL_QUERY_INTERFACE_INHERITED(nsStyledElement, - nsStyledElementBase, - nsStyledElement) +// Using the CC variant of this, even though this class does not define +// a new CC participant, to make QIing to the CC interfaces faster. +NS_IMPL_QUERY_INTERFACE_CYCLE_COLLECTION_INHERITED(nsStyledElement, + nsStyledElementBase, + nsStyledElement) //---------------------------------------------------------------------- // nsIContent methods diff --git a/dom/base/nsTextNode.cpp b/dom/base/nsTextNode.cpp index 3fd45f4668..b91c9e5571 100644 --- a/dom/base/nsTextNode.cpp +++ b/dom/base/nsTextNode.cpp @@ -97,8 +97,13 @@ nsTextNode::~nsTextNode() { } -NS_IMPL_ISUPPORTS_INHERITED(nsTextNode, nsGenericDOMDataNode, nsIDOMNode, - nsIDOMText, nsIDOMCharacterData) +// Using the CC variant of this, even though this class does not define +// a new CC participant, to make QIing to the CC interfaces faster. +NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(nsTextNode, + nsGenericDOMDataNode, + nsIDOMNode, + nsIDOMText, + nsIDOMCharacterData) JSObject* nsTextNode::WrapNode(JSContext *aCx, JS::Handle aGivenProto)