Bug 484898 - Remove unused *_TIMER macros in CNavDTD and nsViewSourceHTML. r=bnewman sr=jst
authorTommy Fogwell
Fri, 14 Aug 2009 09:56:03 -0700
changeset 31565 f58cd3435c4dd2231cde1c288301397bbd611614
parent 31564 3136f5148af4c375be8ac9fd2020b9bc1cfae3aa
child 31566 549f8ed44c5e113f990d5a88883146786e938354
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbnewman, jst
bugs484898
milestone1.9.3a1pre
Bug 484898 - Remove unused *_TIMER macros in CNavDTD and nsViewSourceHTML. r=bnewman sr=jst
parser/htmlparser/src/CNavDTD.cpp
parser/htmlparser/src/nsViewSourceHTML.cpp
--- a/parser/htmlparser/src/CNavDTD.cpp
+++ b/parser/htmlparser/src/CNavDTD.cpp
@@ -75,19 +75,16 @@ static NS_DEFINE_CID(kFormProcessorCID, 
 
 #ifdef DEBUG
 static const  char kNullToken[] = "Error: Null token given";
 static const  char kInvalidTagStackPos[] = "Error: invalid tag stack position";
 #endif
 
 #include "nsElementTable.h"
 
-#define START_TIMER()
-#define STOP_TIMER()
-
 // Some flags for use by the DTD.
 #define NS_DTD_FLAG_NONE                   0x00000000
 #define NS_DTD_FLAG_HAS_OPEN_HEAD          0x00000001
 #define NS_DTD_FLAG_HAS_OPEN_BODY          0x00000002
 #define NS_DTD_FLAG_HAS_OPEN_FORM          0x00000004
 #define NS_DTD_FLAG_HAS_EXPLICIT_HEAD      0x00000008
 #define NS_DTD_FLAG_HAD_BODY               0x00000010
 #define NS_DTD_FLAG_HAD_FRAMESET           0x00000020
@@ -1080,26 +1077,20 @@ CNavDTD::WillHandleStartTag(CToken* aTok
       // the correct node.
       while (stackDepth != MAX_REFLOW_DEPTH && NS_SUCCEEDED(result)) {
         result = CloseContainersTo(mBodyContext->Last(), PR_FALSE);
         --stackDepth;
       }
     }
   }
 
-  STOP_TIMER()
-  MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::WillHandleStartTag(), this=%p\n", this));
-
   if (aTag <= NS_HTML_TAG_MAX) {
     result = mSink->NotifyTagObservers(&aNode);
   }
 
-  MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::WillHandleStartTag(), this=%p\n", this));
-  START_TIMER()
-
   return result;
 }
 
 static void
 PushMisplacedAttributes(nsIParserNode& aNode, nsDeque& aDeque)
 {
   nsCParserNode& theAttrNode = static_cast<nsCParserNode &>(aNode);
 
@@ -1331,26 +1322,21 @@ CNavDTD::HandleStartToken(CToken* aToken
       theHeadIsParent = nsHTMLElement::IsChildOfHead(theChildTag, isExclusive);
 
       switch (theChildTag) {
         case eHTMLTag_area:
           if (!mOpenMapCount) {
             isTokenHandled = PR_TRUE;
           }
 
-          STOP_TIMER();
-          MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::HandleStartToken(), this=%p\n", this));
-
           if (mOpenMapCount > 0 && mSink) {
             result = mSink->AddLeaf(*theNode);
             isTokenHandled = PR_TRUE;
           }
-
-          MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::HandleStartToken(), this=%p\n", this));
-          START_TIMER();
+	  
           break;
 
         case eHTMLTag_image:
           aToken->SetTypeID(theChildTag = eHTMLTag_img);
           break;
 
         case eHTMLTag_keygen:
           result = HandleKeyGen(theNode);
@@ -1772,23 +1758,19 @@ CNavDTD::HandleSavedTokens(PRInt32 anInd
         // Do this to synchronize dtd stack and the sink stack.
         // Note: FORM is never on the dtd stack because its always
         // considered as a leaf. However, in the sink FORM can either
         // be a container or a leaf. Therefore, we have to check
         // with the sink -- Ref: Bug 20087.
         ++anIndex;
       }
 
-      STOP_TIMER()
-      MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::HandleSavedTokensAbove(), this=%p\n", this));
       // Pause the main context and switch to the new context.
       result = mSink->BeginContext(anIndex);
-      MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::HandleSavedTokensAbove(), this=%p\n", this));
-      START_TIMER()
-
+      
       NS_ENSURE_SUCCESS(result, result);
 
       // The body context should contain contents only upto the marked position.
       mBodyContext->MoveEntries(*mTempContext, theTagCount - theTopIndex);
 
       // Now flush out all the bad contents.
       while (theBadTokenCount-- > 0){
         theToken = (CToken*)mMisplacedContent.PopFront();
@@ -1850,22 +1832,18 @@ CNavDTD::HandleSavedTokens(PRInt32 anInd
         // HandleSavedTokens, have the sink close it:
         mSink->CloseContainer(eHTMLTag_form);
       }
 
       // Bad-contents were successfully processed. Now, itz time to get
       // back to the original body context state.
       mTempContext->MoveEntries(*mBodyContext, theTagCount - theTopIndex);
 
-      STOP_TIMER()
-      MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::HandleSavedTokensAbove(), this=%p\n", this));
       // Terminate the new context and switch back to the main context
       mSink->EndContext(anIndex);
-      MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::HandleSavedTokensAbove(), this=%p\n", this));
-      START_TIMER()
 
       mFlags &= ~NS_DTD_FLAG_IN_MISPLACED_CONTENT;
     }
   }
   return result;
 }
 
 
@@ -1931,26 +1909,20 @@ CNavDTD::HandleEntityToken(CToken* aToke
 nsresult
 CNavDTD::HandleCommentToken(CToken* aToken)
 {
   NS_PRECONDITION(nsnull != aToken, kNullToken);
 
   nsCParserNode* theNode = mNodeAllocator.CreateNode(aToken, mTokenAllocator);
   NS_ENSURE_TRUE(theNode, NS_ERROR_OUT_OF_MEMORY);
 
-  STOP_TIMER();
-  MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::HandleCommentToken(), this=%p\n", this));
-
   nsresult result = mSink ? mSink->AddComment(*theNode) : NS_OK;
 
   IF_FREE(theNode, &mNodeAllocator);
 
-  MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::HandleCommentToken(), this=%p\n", this));
-  START_TIMER();
-
   return result;
 }
 
 
 /**
  *  This method gets called when an attribute token has been
  *  encountered in the parse process. This is an error, since
  *  all attributes should have been accounted for in the prior
@@ -1978,26 +1950,20 @@ CNavDTD::HandleAttributeToken(CToken* aT
 nsresult
 CNavDTD::HandleProcessingInstructionToken(CToken* aToken)
 {
   NS_PRECONDITION(nsnull != aToken, kNullToken);
 
   nsCParserNode* theNode = mNodeAllocator.CreateNode(aToken, mTokenAllocator);
   NS_ENSURE_TRUE(theNode, NS_ERROR_OUT_OF_MEMORY);
 
-  STOP_TIMER();
-  MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::HandleProcessingInstructionToken(), this=%p\n", this));
-
   nsresult result = mSink ? mSink->AddProcessingInstruction(*theNode) : NS_OK;
 
   IF_FREE(theNode, &mNodeAllocator);
 
-  MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::HandleProcessingInstructionToken(), this=%p\n", this));
-  START_TIMER();
-
   return result;
 }
 
 /**
  *  This method gets called when a DOCTYPE token has been 
  *  encountered in the parse process. 
  *  
  *  @update  harishd 09/02/99
@@ -2024,26 +1990,21 @@ CNavDTD::HandleDocTypeDeclToken(CToken* 
   }
 
   // Now remove "<!" from the begining
   docTypeStr.Cut(0, 2);
   theToken->SetStringValue(docTypeStr);
 
   nsCParserNode* theNode = mNodeAllocator.CreateNode(aToken, mTokenAllocator);
   NS_ENSURE_TRUE(theNode, NS_ERROR_OUT_OF_MEMORY);
-  STOP_TIMER();
-  MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::HandleDocTypeDeclToken(), this=%p\n", this));
 
   nsresult result = mSink ? mSink->AddDocTypeDecl(*theNode) : NS_OK;
 
   IF_FREE(theNode, &mNodeAllocator);
 
-  MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::HandleDocTypeDeclToken(), this=%p\n", this));
-  START_TIMER();
-
   return result;
 }
 
 /**
  * Retrieve the attributes for this node, and add then into
  * the node.
  *
  * @update  gess4/22/98
@@ -2489,24 +2450,18 @@ CNavDTD::PopStyle(eHTMLTags aTag)
  * @update  gess4/22/98
  * @param   aNode -- next node to be added to model
  */
 nsresult
 CNavDTD::OpenHTML(const nsCParserNode *aNode)
 {
   NS_PRECONDITION(mBodyContext->GetCount() >= 0, kInvalidTagStackPos);
 
-  STOP_TIMER();
-  MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::OpenHTML(), this=%p\n", this));
-
   nsresult result = mSink ? mSink->OpenContainer(*aNode) : NS_OK; 
 
-  MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::OpenHTML(), this=%p\n", this));
-  START_TIMER();
-
   // Don't push more than one HTML tag into the stack.
   if (mBodyContext->GetCount() == 0)  {
     mBodyContext->Push(const_cast<nsCParserNode*>(aNode), 0, PR_FALSE); 
   }
 
   return result;
 }
 
@@ -2523,28 +2478,22 @@ CNavDTD::OpenBody(const nsCParserNode *a
 {
   NS_PRECONDITION(mBodyContext->GetCount() >= 0, kInvalidTagStackPos);
 
   nsresult result = NS_OK;
   
   if (!(mFlags & NS_DTD_FLAG_HAD_FRAMESET)) {
     mFlags |= NS_DTD_FLAG_HAD_BODY;
 
-    STOP_TIMER();
-    MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::OpenBody(), this=%p\n", this));
-
     // Make sure the head is closed by the time the body is opened.
     CloseContainer(eHTMLTag_head, PR_FALSE);
 
     // Now we can open the body.
     result = mSink ? mSink->OpenContainer(*aNode) : NS_OK; 
 
-    MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::OpenBody(), this=%p\n", this));
-    START_TIMER();
-
     if (!HasOpenContainer(eHTMLTag_body)) {
       mBodyContext->Push(const_cast<nsCParserNode*>(aNode), 0, PR_FALSE);
       mTokenizer->PrependTokens(mMisplacedContent);
     }
   }
 
   return result;
 }
@@ -2657,24 +2606,19 @@ CNavDTD::OpenContainer(const nsCParserNo
       break;
 
     default:
       done = PR_FALSE;
       break;
   }
 
   if (!done) {
-    STOP_TIMER();
-    MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::OpenContainer(), this=%p\n", this));
 
     result = mSink ? mSink->OpenContainer(*aNode) : NS_OK;
 
-    MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::OpenContainer(), this=%p\n", this));
-    START_TIMER();
-
     // For residual style tags rs_tag will be true and hence
     // the body context will hold an extra reference to the node.
     mBodyContext->Push(const_cast<nsCParserNode*>(aNode), aStyleStack, rs_tag); 
   }
 
   return result;
 }
 
@@ -2748,18 +2692,16 @@ CNavDTD::CloseContainer(const eHTMLTags 
       mFlags &= ~NS_DTD_FLAG_ALTERNATE_CONTENT;
 
       // falling thro' intentionally....
     default:
       done = PR_FALSE;
   }
 
   if (!done) {
-    STOP_TIMER();
-    MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::CloseContainer(), this=%p\n", this));
 
     if (mSink) {
       result = !aMalformed
                ? mSink->CloseContainer(aTag)
                : mSink->CloseMalformedContainer(aTag);
     }
 
     // If we were dealing with a head container in the body, make sure to
@@ -2771,19 +2713,16 @@ CNavDTD::CloseContainer(const eHTMLTags 
 
       // Note: we could be assigning NS_OK into NS_OK here, but that's ok.
       // This test is to avoid a successful CloseHead result stomping over a
       // request to block the parser.
       if (NS_SUCCEEDED(result)) {
         result = headresult;
       }
     }
-
-    MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::CloseContainer(), this=%p\n", this));
-    START_TIMER();
   }
 
   return result;
 }
 
 /**
  * This method does two things: 1st, help construct
  * our own internal model of the content-stack; and
@@ -2997,23 +2936,17 @@ nsresult
 CNavDTD::AddLeaf(const nsIParserNode *aNode)
 {
   nsresult result = NS_OK;
 
   if (mSink) {
     eHTMLTags theTag = (eHTMLTags)aNode->GetNodeType();
     OpenTransientStyles(theTag);
 
-    STOP_TIMER();
-    MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::AddLeaf(), this=%p\n", this));
-
     result = mSink->AddLeaf(*aNode);
-
-    MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::AddLeaf(), this=%p\n", this));
-    START_TIMER();
   }
 
   return result;
 }
 
 /**
  * Call this method ONLY when you want to write a leaf
  * into the head container.
@@ -3036,19 +2969,16 @@ CNavDTD::AddHeadContent(nsIParserNode *a
   // SCRIPT inside NOTAGS.  Ref Bug 25880.
   if (eHTMLTag_meta == theTag || eHTMLTag_script == theTag) {
     if (HasOpenContainer(gNoXTags, NS_ARRAY_LENGTH(gNoXTags))) {
       return result;
     }
   }
 
   if (mSink) {
-    STOP_TIMER();
-    MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::AddHeadContent(), this=%p\n", this));
-
     // Make sure the head is opened.
     if (!(mFlags & NS_DTD_FLAG_HAS_OPEN_HEAD)) {
       result = mSink->OpenHead();
       mBodyContext->PushTag(eHTMLTag_head);
       mFlags |= NS_DTD_FLAG_HAS_OPEN_HEAD;
     }
 
     // Note: userdefined tags in the head are treated as leaves.
@@ -3068,19 +2998,16 @@ CNavDTD::AddHeadContent(nsIParserNode *a
       }
 
       // Note: The head context is already opened.
       result = mSink->OpenContainer(*aNode);
 
       mBodyContext->Push(static_cast<nsCParserNode*>(aNode), nsnull,
                          PR_FALSE);
     }
-
-    MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::AddHeadContent(), this=%p\n", this));
-    START_TIMER();
   }
 
   return result;
 }
 
 void
 CNavDTD::CreateContextStackFor(eHTMLTags aParent, eHTMLTags aChild)
 {
--- a/parser/htmlparser/src/nsViewSourceHTML.cpp
+++ b/parser/htmlparser/src/nsViewSourceHTML.cpp
@@ -42,20 +42,16 @@
 
 /*
  * Set NS_VIEWSOURCE_TOKENS_PER_BLOCK to 0 to disable multi-block
  * output.  Multi-block output helps reduce the amount of bidi
  * processing we have to do on the resulting content model.
  */
 #define NS_VIEWSOURCE_TOKENS_PER_BLOCK 16
 
-// TODO get rid of these unused macros
-#define STOP_TIMER()
-#define START_TIMER()
-
 #include "nsIAtom.h"
 #include "nsViewSourceHTML.h"
 #include "nsCRT.h"
 #include "nsParser.h"
 #include "nsScanner.h"
 #include "nsDTDUtils.h"
 #include "nsIContentSink.h"
 #include "nsIHTMLContentSink.h"
@@ -256,17 +252,16 @@ CViewSourceHTML::WillBuildModel(const CP
 {
   nsresult result=NS_OK;
 
 #ifdef RAPTOR_PERF_METRICS
   vsTimer.Reset();
   NS_START_STOPWATCH(vsTimer);
 #endif
 
-  STOP_TIMER();
   mSink=(nsIHTMLContentSink*)aSink;
 
   if((!aParserContext.mPrevContext) && (mSink)) {
 
     nsAString & contextFilename = aParserContext.mScanner->GetFilename();
     mFilename = Substring(contextFilename,
                           12, // The length of "view-source:"
                           contextFilename.Length() - 12);
@@ -297,18 +292,16 @@ CViewSourceHTML::WillBuildModel(const CP
 
 
   if(eViewSource!=aParserContext.mParserCommand)
     mDocType=ePlainText;
   else mDocType=aParserContext.mDocType;
 
   mLineNumber = 1;
 
-  START_TIMER();
-
   return result;
 }
 
 /**
   * The parser uses a code sandwich to wrap the parsing process. Before
   * the process begins, WillBuildModel() is called. Afterwards the parser
   * calls DidBuildModel().
   * @update gess5/18/98
@@ -535,18 +528,16 @@ void CViewSourceHTML::AddAttrToNode(nsCP
  * @return
  */
 NS_IMETHODIMP CViewSourceHTML::DidBuildModel(nsresult anErrorCode)
 {
   nsresult result= NS_OK;
 
   //ADD CODE HERE TO CLOSE OPEN CONTAINERS...
 
-  STOP_TIMER();
-
   if (mSink) {
       //now let's close automatically auto-opened containers...
 
 #ifdef DUMP_TO_FILE
     if(gDumpFile) {
       fprintf(gDumpFile, "</pre>\n");
       fprintf(gDumpFile, "</body>\n");
       fprintf(gDumpFile, "</html>\n");
@@ -556,18 +547,16 @@ NS_IMETHODIMP CViewSourceHTML::DidBuildM
 
     if(ePlainText!=mDocType) {
       mSink->CloseContainer(eHTMLTag_pre);
       mSink->CloseContainer(eHTMLTag_body);
       mSink->CloseContainer(eHTMLTag_html);
     }
   }
 
-  START_TIMER();
-
 #ifdef RAPTOR_PERF_METRICS
   NS_STOP_STOPWATCH(vsTimer);
   printf("viewsource timer: ");
   vsTimer.Print();
   printf("\n");
 #endif
 
   return result;
@@ -764,18 +753,16 @@ nsresult CViewSourceHTML::WriteTag(PRInt
     if (gDumpFile) {
       fprintf(gDumpFile, "<span class=\"");
       fprintf(gDumpFile, kElementClasses[aTagType]);
       fprintf(gDumpFile, "\">");
     }
 #endif // DUMP_TO_FILE
   }
 
-  STOP_TIMER();
-
   mITextToken.SetIndirectString(aText);  //now emit the tag name...
 
   nsCParserNode theNode(&mITextToken, 0/*stack token*/);
   mSink->AddLeaf(theNode);
 #ifdef DUMP_TO_FILE
   if (gDumpFile) {
     fputs(NS_ConvertUTF16toUTF8(aText).get(), gDumpFile);
   }
@@ -811,18 +798,16 @@ nsresult CViewSourceHTML::WriteTag(PRInt
     mErrorNode.ReleaseAll();
     mSink->CloseContainer(eHTMLTag_span);  //emit </endtag>...
 #ifdef DUMP_TO_FILE
     if (gDumpFile)
       fprintf(gDumpFile, "</span>");
 #endif //DUMP_TO_FILE
   }
 
-  START_TIMER();
-
   return result;
 }
 
 /**
  *
  *  @update  gess 3/25/98
  *  @param   aToken -- token object to be put into content model
  *  @return  0 if all is well; non-zero is an error