Bug 1384669: Reduce refcount churn in BidiParagraphData by using non-refcounted pointer hash keys. r?jfkthame draft
authorDaniel Holbert <dholbert@cs.stanford.edu>
Wed, 26 Jul 2017 12:47:53 -0700
changeset 616156 f298f2c9b4217118c8654a5a6d1a428c7672860b
parent 615618 ae7f1e8f2b350dc6b808d79b32d4dc13b17fc6a9
child 639403 3fde47e44b4fa0c95c52c81b886d1df4097017a9
push id70610
push userdholbert@mozilla.com
push dateWed, 26 Jul 2017 19:48:01 +0000
reviewersjfkthame
bugs1384669
milestone56.0a1
Bug 1384669: Reduce refcount churn in BidiParagraphData by using non-refcounted pointer hash keys. r?jfkthame We don't need to bother with refcounting for these pointers, because they're pointing to DOM elements, and the DOM is basically immutable during reflow. And BidiParagraphData is a stack-only class which only lives for a short period of reflow - so it can assume these pointers' targets will stick around for its whole life. MozReview-Commit-ID: J3SfRYoRweX
layout/base/nsBidiPresUtils.cpp
--- a/layout/base/nsBidiPresUtils.cpp
+++ b/layout/base/nsBidiPresUtils.cpp
@@ -11,16 +11,17 @@
 #include "nsFontMetrics.h"
 #include "nsGkAtoms.h"
 #include "nsPresContext.h"
 #include "nsBidiUtils.h"
 #include "nsCSSFrameConstructor.h"
 #include "nsContainerFrame.h"
 #include "nsInlineFrame.h"
 #include "nsPlaceholderFrame.h"
+#include "nsPointerHashKeys.h"
 #include "nsFirstLetterFrame.h"
 #include "nsUnicodeProperties.h"
 #include "nsTextFrame.h"
 #include "nsBlockFrame.h"
 #include "nsIFrameInlines.h"
 #include "nsStyleStructInlines.h"
 #include "RubyUtils.h"
 #include "nsRubyFrame.h"
@@ -127,17 +128,18 @@ GetBidiControl(nsStyleContext* aStyleCon
 }
 
 struct MOZ_STACK_CLASS BidiParagraphData
 {
   nsAutoString        mBuffer;
   AutoTArray<char16_t, 16> mEmbeddingStack;
   AutoTArray<nsIFrame*, 16> mLogicalFrames;
   AutoTArray<nsLineBox*, 16> mLinePerFrame;
-  nsDataHashtable<nsISupportsHashKey, int32_t> mContentToFrameIndex;
+  nsDataHashtable<nsPtrHashKey<const nsIContent>, int32_t>
+    mContentToFrameIndex;
   // Cached presentation context for the frames we're processing.
   nsPresContext*      mPresContext;
   bool                mIsVisual;
   bool                mRequiresBidi;
   nsBidiLevel         mParaLevel;
   nsIContent*         mPrevContent;
   nsIFrame*           mPrevFrame;
 #ifdef DEBUG