Closed Bug 124870 Opened 23 years ago Closed 23 years ago

[FIX]patch for shrinking the size of some htmlparser data structures

Categories

(Core :: DOM: HTML Parser, defect, P4)

defect

Tracking

()

RESOLVED FIXED
mozilla1.2alpha

People

(Reporter: dann, Assigned: bzbarsky)

Details

(Keywords: memory-footprint, Whiteboard: [fixinhand?])

Attachments

(1 file)

This is a continuation of the work in bug# 113657 Mostly replacing PRBools (that are normally 4byte) with PRPackedBool (1byte) and arranging them together so that the alignment requirements don't spoil the space advantage of PRPackedBool The members of the class CStartToken in htmlparser/public/nsHTMLTokens.h are rearranged so that the mEmpty fits in the slot at the end of CToken (the last memeber of that class is PRInt16) --- ./htmlparser/public/nsHTMLTokens.h.~1.4.~ Fri Jan 11 11:39:55 2002 +++ ./htmlparser/public/nsHTMLTokens.h Wed Feb 6 11:38:07 2002 @@ -149,16 +149,18 @@ class CStartToken: public CHTMLToken { */ virtual nsresult GetIDAttributeAtom(nsIAtom** aResult); virtual nsresult SetIDAttributeAtom(nsIAtom* aID); + protected: + PRPackedBool mEmpty; +#ifdef DEBUG + PRPackedBool mAttributed; +#endif + public: nsString mTextValue; nsString mTrailingContent; protected: eContainerInfo mContainerInfo; nsCOMPtr<nsIAtom> mIDAttributeAtom; - PRPackedBool mEmpty; -#ifdef DEBUG - PRPackedBool mAttributed; -#endif }; @@ -379,12 +381,12 @@ class CAttributeToken: public CHTMLToken #endif PRPackedBool mHasEqualWithoutValue; - protected: - nsAutoString mTextValue; - nsSlidingSubstring mTextKey; #ifdef DEBUG PRPackedBool mLastAttribute; #endif +protected: + nsAutoString mTextValue; + nsSlidingSubstring mTextKey; }; --- ./htmlparser/src/nsScanner.h.~3.57.~ Tue Dec 25 19:17:51 2001 +++ ./htmlparser/src/nsScanner.h Wed Feb 6 11:39:17 2002 @@ -391,8 +391,8 @@ class nsScanner { PRUint32 mCountRemaining; // The number of bytes still to be read // from the scanner buffer PRUint32 mTotalRead; - PRBool mOwnsStream; - PRBool mIncremental; + PRPackedBool mOwnsStream; + PRPackedBool mIncremental; PRInt32 mCharsetSource; nsString mCharset; nsIUnicodeDecoder *mUnicodeDecoder; --- ./htmlparser/src/prstrm.h.~3.8.~ Tue Sep 25 17:39:32 2001 +++ ./htmlparser/src/prstrm.h Wed Feb 6 15:32:06 2002 @@ -113,8 +113,8 @@ public: private: PRFileDesc * _fd; - PRBool _opened; - PRBool _allocated; + PRPackedBool _opened; + PRPackedBool _allocated; }; --- ./htmlparser/src/COtherDTD.h.~3.60.~ Tue Jan 8 17:37:22 2002 +++ ./htmlparser/src/COtherDTD.h Wed Feb 6 11:43:24 2002 @@ -166,19 +166,20 @@ protected: nsIHTMLContentSink* mSink; nsDTDContext* mBodyContext; - PRBool mHasOpenForm; - PRBool mHasOpenMap; PRInt32 mHasOpenHead; - PRBool mHasOpenBody; - PRBool mHadFrameset; - PRBool mHadBody; + PRPackedBool mHasOpenForm; + PRPackedBool mHasOpenMap; + PRPackedBool mHasOpenBody; + PRPackedBool mHadFrameset; + PRPackedBool mHadBody; + PRPackedBool mHasOpenScript; + PRPackedBool mEnableStrict; nsString mFilename; PRInt32 mLineNumber; nsParser* mParser; nsITokenizer* mTokenizer; nsTokenAllocator* mTokenAllocator; nsNodeAllocator* mNodeAllocator; - PRBool mHasOpenScript; eHTMLTags mSkipTarget; nsresult mDTDState; nsDTDMode mDTDMode; @@ -188,7 +189,7 @@ protected: PRUint32 mExpectedCRC32; nsString mScratch; //used for various purposes; non-persistent eParserDocType mDocType; - PRBool mEnableStrict; + }; --- ./htmlparser/src/COtherElements.h.~3.50.~ Fri Jan 11 11:33:30 2002 +++ ./htmlparser/src/COtherElements.h Wed Feb 6 11:44:32 2002 @@ -430,7 +430,7 @@ public: static CGroupMembers& GetContainedGroups(void) { static CGroupMembers theGroup={0}; - static PRBool initialized=PR_FALSE; + static PRPackedBool initialized=PR_FALSE; if(!initialized) { initialized=PR_TRUE; theGroup.mBits.mFormControl=1; --- ./htmlparser/src/CParserContext.h.~3.33.~ Tue Jan 8 17:37:22 2002 +++ ./htmlparser/src/CParserContext.h Wed Feb 6 11:46:15 2002 @@ -98,8 +98,8 @@ public: eAutoDetectResult mAutoDetectStatus; eParserCommands mParserCommand; //tells us to viewcontent/viewsource/viewerrors... - PRBool mMultipart; - PRBool mCopyUnused; + PRPackedBool mMultipart; + PRPackedBool mCopyUnused; PRUint32 mTransferBufferSize; }; --- ./htmlparser/src/nsDTDUtils.h.~3.69.~ Fri Jan 11 11:33:31 2002 +++ ./htmlparser/src/nsDTDUtils.h Wed Feb 6 15:31:59 2002 @@ -222,12 +222,12 @@ public: return result; } - PRBool mHasCaption; - PRBool mHasCols; - PRBool mHasTHead; - PRBool mHasTFoot; - PRBool mHasTBody; - CTableState *mPrevious; + PRPackedBool mHasCaption; + PRPackedBool mHasCols; + PRPackedBool mHasTHead; + PRPackedBool mHasTFoot; + PRPackedBool mHasTBody; + CTableState *mPrevious; }; #ifdef DEBUG --- ./htmlparser/src/nsHTMLTokenizer.h.~3.29.~ Tue Jan 8 17:37:23 2002 +++ ./htmlparser/src/nsHTMLTokenizer.h Wed Feb 6 11:51:13 2002 @@ -101,10 +101,11 @@ protected: nsDeque mTokenDeque; PRInt32 mFlags; - PRBool mRecordTrailingContent; + PRPackedBool mRecordTrailingContent; + PRPackedBool mIsFinalChunk; nsTokenAllocator* mTokenAllocator; PRInt32 mTokenScanPos; - PRBool mIsFinalChunk; + }; extern nsresult NS_NewHTMLTokenizer( nsITokenizer** aInstancePtrResult, --- ./htmlparser/src/nsHTMLContentSinkStream.h.~3.54.~ Tue Sep 25 17:39:28 2001 +++ ./htmlparser/src/nsHTMLContentSinkStream.h Wed Feb 6 11:50:14 2002 @@ -202,19 +202,21 @@ protected: PRInt32 mBufferLength; PRInt32 mIndent; - PRBool mLowerCaseTags; PRInt32 mHTMLStackPos; - eHTMLTags mHTMLTagStack[1024]; // warning: hard-coded nesting level - PRBool mDirtyStack[1024]; // warning: hard-coded nesting level + + PRPackedBool mLowerCaseTags; + PRPackedBool mDoFormat; + PRPackedBool mBodyOnly; + PRPackedBool mHasOpenHtmlTag; + PRPackedBool mInBody; + PRPackedBool mDirtyStack[1024]; // warning: hard-coded nesting level + eHTMLTags mHTMLTagStack[1024]; // warning: hard-coded nesting level + PRInt32 mColPos; - PRBool mInBody; PRUint32 mFlags; nsCOMPtr<nsIURI> mURI; - PRBool mDoFormat; - PRBool mBodyOnly; - PRBool mHasOpenHtmlTag; PRInt32 mPreLevel; PRInt32 mMaxColumn; --- ./htmlparser/src/nsLoggingSink.h.~3.14.~ Tue Jan 8 17:37:23 2002 +++ ./htmlparser/src/nsLoggingSink.h Wed Feb 6 11:51:38 2002 @@ -113,7 +113,7 @@ protected: PRFileDesc *mOutput; int mLevel; nsIHTMLContentSink *mSink; - PRBool mAutoDeleteOutput; + PRPackedBool mAutoDeleteOutput; }; #endif --- ./htmlparser/src/nsViewSourceHTML.h.~1.45.~ Tue Jan 8 17:37:26 2002 +++ ./htmlparser/src/nsViewSourceHTML.h Wed Feb 6 12:02:29 2002 @@ -105,8 +105,12 @@ protected: PRInt32 mValue; PRInt32 mPopupTag; PRInt32 mSummaryTag; - PRBool mSyntaxHighlight; - PRBool mWrapLongLines; + PRPackedBool mSyntaxHighlight; + PRPackedBool mWrapLongLines; + PRPackedBool mShowErrors; + PRPackedBool mHasOpenRoot; + PRPackedBool mHasOpenBody; + PRPackedBool mInCDATAContainer; nsDTDMode mDTDMode; eParserCommands mParserCommand; //tells us to viewcontent/viewsource/viewerrors... @@ -119,10 +123,6 @@ protected: nsString mFilename; nsString mTags; nsString mErrors; - PRBool mShowErrors; - PRBool mHasOpenRoot; - PRBool mHasOpenBody; - PRBool mInCDATAContainer; }; extern nsresult NS_NewViewSourceHTML(nsIDTD** aInstancePtrResult);
please make sure to reorder initializers to match the class declaration order (that will prevent some compiler warnings).
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: footprint, patch, review
I went over it and none of the members that I reordered is used in an initializer. I hope I did't miss any...
--> 1.0
Status: NEW → ASSIGNED
Priority: -- → P4
Target Milestone: --- → mozilla1.0
Moving Netscape owned 0.9.9 and 1.0 bugs that don't have an nsbeta1, nsbeta1+, topembed, topembed+, Mozilla0.9.9+ or Mozilla1.0+ keyword. Please send any questions or feedback about this to adt@netscape.com. You can search for "Moving bugs not scheduled for a project" to quickly delete this bugmail.
Target Milestone: mozilla1.0 → mozilla1.2
Boris, could you take care of this, looks again trivial...
Assignee: harishd → bzbarsky
Severity: normal → minor
Status: ASSIGNED → NEW
OS: Linux → All
Hardware: PC → All
Whiteboard: [fixinhand?]
reviews?
Summary: patch for shrinking the size of some htmlparser data structures → [FIX]patch for shrinking the size of some htmlparser data structures
Comment on attachment 93826 [details] [diff] [review] patch updated to tip r=heikki provided that you check we don't get any extra compiler warnings (for example from wrong order of initialization in constructors)
Attachment #93826 - Flags: review+
That's what I said in comment 1. ;) Both dan and I have checked this.
Comment on attachment 93826 [details] [diff] [review] patch updated to tip sr=jst
Attachment #93826 - Flags: superreview+
checked in.
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: