summaryrefslogtreecommitdiff
path: root/dom/base/CustomElementRegistry.h
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2020-01-04 10:34:36 -0500
committerGaming4JC <g4jc@hyperbola.info>2020-01-26 15:50:15 -0500
commitd8109fa9a0aae6ee09eca1d6b5cfab285af318f9 (patch)
tree0fa205b178976873c535ca2763dba3c9ba932bf3 /dom/base/CustomElementRegistry.h
parente0557470385b6f7c1ab8e277b2b72a5146856fe6 (diff)
downloaduxp-d8109fa9a0aae6ee09eca1d6b5cfab285af318f9.tar.gz
Bug 1309147 - Part 5: Eliminate performance cliff when accessing CEReactions code.
Tag UXP Issue #1344
Diffstat (limited to 'dom/base/CustomElementRegistry.h')
-rw-r--r--dom/base/CustomElementRegistry.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/dom/base/CustomElementRegistry.h b/dom/base/CustomElementRegistry.h
index 5fc2eb2fde..24d501d73e 100644
--- a/dom/base/CustomElementRegistry.h
+++ b/dom/base/CustomElementRegistry.h
@@ -179,7 +179,8 @@ public:
// nsWeakPtr is a weak pointer of Element
// The element reaction queues are stored in ElementReactionQueueMap.
// We need to lookup ElementReactionQueueMap again to get relevant reaction queue.
- typedef nsTArray<nsWeakPtr> ElementQueue;
+ // The choice of 1 for the auto size here is based on gut feeling.
+ typedef AutoTArray<nsWeakPtr, 1> ElementQueue;
/**
* Enqueue a custom element upgrade reaction
@@ -201,13 +202,19 @@ public:
private:
~CustomElementReactionsStack() {};
- typedef nsTArray<nsAutoPtr<CustomElementReaction>> ReactionQueue;
+ // There is 1 reaction in reaction queue, when 1) it becomes disconnected,
+ // 2) it’s adopted into a new document, 3) its attributes are changed,
+ // appended, removed, or replaced.
+ // There are 3 reactions in reaction queue when doing upgrade operation,
+ // e.g., create an element, insert a node.
+ typedef AutoTArray<nsAutoPtr<CustomElementReaction>, 3> ReactionQueue;
typedef nsClassHashtable<nsISupportsHashKey, ReactionQueue>
ElementReactionQueueMap;
ElementReactionQueueMap mElementReactionQueueMap;
- nsTArray<ElementQueue> mReactionsStack;
+ // The choice of 8 for the auto size here is based on gut feeling.
+ AutoTArray<ElementQueue, 8> mReactionsStack;
ElementQueue mBackupQueue;
// https://html.spec.whatwg.org/#enqueue-an-element-on-the-appropriate-element-queue
bool mIsBackupQueueProcessing;