Bug 1330226 - BidiParagraphData should allocate less, r=jfkthame
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Thu, 12 Jan 2017 22:46:23 +0800
changeset 374145 0733a44cd6c5b9beeddbe55a984f013167ca3ea8
parent 374144 d80f960a1f2db3997aba01e87d40b2ff087a2ead
child 374146 305dcbada31f5a562de11530dcfbbedd9f60c482
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1330226
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1330226 - BidiParagraphData should allocate less, r=jfkthame
layout/base/nsBidiPresUtils.cpp
--- a/layout/base/nsBidiPresUtils.cpp
+++ b/layout/base/nsBidiPresUtils.cpp
@@ -121,31 +121,31 @@ GetBidiControl(nsStyleContext* aStyleCon
     return NS_STYLE_DIRECTION_RTL == vis->mDirection ? kRLI : kLRI;
   }
   if (text->mUnicodeBidi & NS_STYLE_UNICODE_BIDI_PLAINTEXT) {
     return kFSI;
   }
   return 0;
 }
 
-struct BidiParagraphData {
-  nsString            mBuffer;
+struct MOZ_STACK_CLASS BidiParagraphData
+{
+  nsAutoString        mBuffer;
   AutoTArray<char16_t, 16> mEmbeddingStack;
-  nsTArray<nsIFrame*> mLogicalFrames;
-  nsTArray<nsLineBox*> mLinePerFrame;
+  AutoTArray<nsIFrame*, 16> mLogicalFrames;
+  AutoTArray<nsLineBox*, 16> mLinePerFrame;
   nsDataHashtable<nsISupportsHashKey, int32_t> mContentToFrameIndex;
   bool                mIsVisual;
   nsBidiLevel         mParaLevel;
   nsIContent*         mPrevContent;
-  nsAutoPtr<nsBidi>   mBidiEngine;
+  nsBidi              mBidiEngine;
   nsIFrame*           mPrevFrame;
 
   void Init(nsBlockFrame *aBlockFrame)
   {
-    mBidiEngine = new nsBidi();
     mPrevContent = nullptr;
 
     mParaLevel = nsBidiPresUtils::BidiLevelFromStyle(aBlockFrame->StyleContext());
 
     mIsVisual = aBlockFrame->PresContext()->IsVisualMode();
     if (mIsVisual) {
       /**
        * Drill up in content to detect whether this is an element that needs to
@@ -169,49 +169,49 @@ struct BidiParagraphData {
           break;
         }
       }
     }
   }
 
   nsresult SetPara()
   {
-    return mBidiEngine->SetPara(mBuffer.get(), BufferLength(),
-                                mParaLevel);
+    return mBidiEngine.SetPara(mBuffer.get(), BufferLength(),
+                               mParaLevel);
   }
 
   /**
    * mParaLevel can be NSBIDI_DEFAULT_LTR as well as NSBIDI_LTR or NSBIDI_RTL.
    * GetParaLevel() returns the actual (resolved) paragraph level which is
    * always either NSBIDI_LTR or NSBIDI_RTL
    */
   nsBidiLevel GetParaLevel()
   {
     nsBidiLevel paraLevel = mParaLevel;
     if (paraLevel == NSBIDI_DEFAULT_LTR || paraLevel == NSBIDI_DEFAULT_RTL) {
-      mBidiEngine->GetParaLevel(&paraLevel);
+      mBidiEngine.GetParaLevel(&paraLevel);
     }
     return paraLevel;
   }
 
   nsBidiDirection GetDirection()
   {
     nsBidiDirection dir;
-    mBidiEngine->GetDirection(&dir);
+    mBidiEngine.GetDirection(&dir);
     return dir;
   }
 
-  nsresult CountRuns(int32_t *runCount){ return mBidiEngine->CountRuns(runCount); }
+  nsresult CountRuns(int32_t *runCount){ return mBidiEngine.CountRuns(runCount); }
 
   nsresult GetLogicalRun(int32_t aLogicalStart, 
                          int32_t* aLogicalLimit,
                          nsBidiLevel* aLevel)
   {
-    nsresult rv = mBidiEngine->GetLogicalRun(aLogicalStart,
-                                             aLogicalLimit, aLevel);
+    nsresult rv = mBidiEngine.GetLogicalRun(aLogicalStart,
+                                            aLogicalLimit, aLevel);
     if (mIsVisual || NS_FAILED(rv))
       *aLevel = GetParaLevel();
     return rv;
   }
 
   void ResetData()
   {
     mLogicalFrames.Clear();