Fix bug #242044 - Reduce number of allocations by nsSpaceManager::PushState

This commit is contained in:
jim_nance%yahoo.com 2004-06-06 18:45:02 +00:00
Родитель d0523b301a
Коммит dbdb7cf917
4 изменённых файлов: 32 добавлений и 14 удалений

Просмотреть файл

@ -133,7 +133,7 @@ nsSpaceManager::~nsSpaceManager()
NS_ASSERTION(!mSavedStates, "states remaining on state stack"); NS_ASSERTION(!mSavedStates, "states remaining on state stack");
while (mSavedStates){ while (mSavedStates && mSavedStates != &mAutoState){
SpaceManagerState *state = mSavedStates; SpaceManagerState *state = mSavedStates;
mSavedStates = state->mNext; mSavedStates = state->mNext;
delete state; delete state;
@ -979,7 +979,13 @@ nsSpaceManager::PushState()
// Allowing mFloatDamage to accumulate the damage incurred during both // Allowing mFloatDamage to accumulate the damage incurred during both
// reflows ensures that nothing gets missed. // reflows ensures that nothing gets missed.
SpaceManagerState *state = new SpaceManagerState; SpaceManagerState *state;
if(mSavedStates) {
state = new SpaceManagerState;
} else {
state = &mAutoState;
}
NS_ASSERTION(state, "PushState() failed!"); NS_ASSERTION(state, "PushState() failed!");
@ -994,6 +1000,8 @@ nsSpaceManager::PushState()
if (mFrameInfoMap) { if (mFrameInfoMap) {
state->mLastFrame = mFrameInfoMap->mFrame; state->mLastFrame = mFrameInfoMap->mFrame;
} else {
state->mLastFrame = nsnull;
} }
// Now that we've saved our state, add it to mSavedStates. // Now that we've saved our state, add it to mSavedStates.
@ -1038,11 +1046,14 @@ nsSpaceManager::PopState()
mLowestTop = mSavedStates->mLowestTop; mLowestTop = mSavedStates->mLowestTop;
// Now that we've restored our state, pop the topmost // Now that we've restored our state, pop the topmost
// state and delete it. // state and delete it. Make sure not to delete the mAutoState element
// as it is embeded in this class
SpaceManagerState *state = mSavedStates; SpaceManagerState *state = mSavedStates;
mSavedStates = mSavedStates->mNext; mSavedStates = mSavedStates->mNext;
delete state; if(state != &mAutoState) {
delete state;
}
} }
nscoord nscoord

Просмотреть файл

@ -332,9 +332,6 @@ protected:
nscoord mXMost; nscoord mXMost;
nscoord mLowestTop; nscoord mLowestTop;
SpaceManagerState *mNext; SpaceManagerState *mNext;
SpaceManagerState() : mX(0), mY(0), mLastFrame(nsnull), mNext(nsnull) {}
~SpaceManagerState() {}
}; };
public: public:
@ -411,6 +408,7 @@ protected:
nsIntervalSet mFloatDamage; nsIntervalSet mFloatDamage;
SpaceManagerState *mSavedStates; SpaceManagerState *mSavedStates;
SpaceManagerState mAutoState;
protected: protected:
FrameInfo* GetFrameInfoFor(nsIFrame* aFrame); FrameInfo* GetFrameInfoFor(nsIFrame* aFrame);

Просмотреть файл

@ -133,7 +133,7 @@ nsSpaceManager::~nsSpaceManager()
NS_ASSERTION(!mSavedStates, "states remaining on state stack"); NS_ASSERTION(!mSavedStates, "states remaining on state stack");
while (mSavedStates){ while (mSavedStates && mSavedStates != &mAutoState){
SpaceManagerState *state = mSavedStates; SpaceManagerState *state = mSavedStates;
mSavedStates = state->mNext; mSavedStates = state->mNext;
delete state; delete state;
@ -979,7 +979,13 @@ nsSpaceManager::PushState()
// Allowing mFloatDamage to accumulate the damage incurred during both // Allowing mFloatDamage to accumulate the damage incurred during both
// reflows ensures that nothing gets missed. // reflows ensures that nothing gets missed.
SpaceManagerState *state = new SpaceManagerState; SpaceManagerState *state;
if(mSavedStates) {
state = new SpaceManagerState;
} else {
state = &mAutoState;
}
NS_ASSERTION(state, "PushState() failed!"); NS_ASSERTION(state, "PushState() failed!");
@ -994,6 +1000,8 @@ nsSpaceManager::PushState()
if (mFrameInfoMap) { if (mFrameInfoMap) {
state->mLastFrame = mFrameInfoMap->mFrame; state->mLastFrame = mFrameInfoMap->mFrame;
} else {
state->mLastFrame = nsnull;
} }
// Now that we've saved our state, add it to mSavedStates. // Now that we've saved our state, add it to mSavedStates.
@ -1038,11 +1046,14 @@ nsSpaceManager::PopState()
mLowestTop = mSavedStates->mLowestTop; mLowestTop = mSavedStates->mLowestTop;
// Now that we've restored our state, pop the topmost // Now that we've restored our state, pop the topmost
// state and delete it. // state and delete it. Make sure not to delete the mAutoState element
// as it is embeded in this class
SpaceManagerState *state = mSavedStates; SpaceManagerState *state = mSavedStates;
mSavedStates = mSavedStates->mNext; mSavedStates = mSavedStates->mNext;
delete state; if(state != &mAutoState) {
delete state;
}
} }
nscoord nscoord

Просмотреть файл

@ -332,9 +332,6 @@ protected:
nscoord mXMost; nscoord mXMost;
nscoord mLowestTop; nscoord mLowestTop;
SpaceManagerState *mNext; SpaceManagerState *mNext;
SpaceManagerState() : mX(0), mY(0), mLastFrame(nsnull), mNext(nsnull) {}
~SpaceManagerState() {}
}; };
public: public:
@ -411,6 +408,7 @@ protected:
nsIntervalSet mFloatDamage; nsIntervalSet mFloatDamage;
SpaceManagerState *mSavedStates; SpaceManagerState *mSavedStates;
SpaceManagerState mAutoState;
protected: protected:
FrameInfo* GetFrameInfoFor(nsIFrame* aFrame); FrameInfo* GetFrameInfoFor(nsIFrame* aFrame);