Use a stack array for the pending restyles unless there are lots of them. Bug 403113, r+sr+a=roc

This commit is contained in:
bzbarsky@mit.edu 2007-11-08 22:09:22 -08:00
parent f531bf7329
commit d3d73c426f

View File

@ -13218,6 +13218,8 @@ nsCSSFrameConstructor::ProcessOneRestyle(nsIContent* aContent,
}
}
#define RESTYLE_ARRAY_STACKSIZE 128
void
nsCSSFrameConstructor::ProcessPendingRestyles()
{
@ -13229,17 +13231,18 @@ nsCSSFrameConstructor::ProcessPendingRestyles()
NS_PRECONDITION(mDocument, "No document? Pshaw!\n");
nsCSSFrameConstructor::RestyleEnumerateData* restylesToProcess =
new nsCSSFrameConstructor::RestyleEnumerateData[count];
// Use the stack if we can, otherwise fall back on heap-allocation.
nsAutoTArray<RestyleEnumerateData, RESTYLE_ARRAY_STACKSIZE> restyleArr;
RestyleEnumerateData* restylesToProcess = restyleArr.AppendElements(count);
if (!restylesToProcess) {
return;
}
nsCSSFrameConstructor::RestyleEnumerateData* lastRestyle = restylesToProcess;
RestyleEnumerateData* lastRestyle = restylesToProcess;
mPendingRestyles.Enumerate(CollectRestyles, &lastRestyle);
NS_ASSERTION(lastRestyle - restylesToProcess ==
PRInt32(count),
NS_ASSERTION(lastRestyle - restylesToProcess == PRInt32(count),
"Enumeration screwed up somehow");
// Clear the hashtable so we don't end up trying to process a restyle we're
@ -13250,8 +13253,7 @@ nsCSSFrameConstructor::ProcessPendingRestyles()
// processing restyles
BeginUpdate();
for (nsCSSFrameConstructor::RestyleEnumerateData* currentRestyle =
restylesToProcess;
for (RestyleEnumerateData* currentRestyle = restylesToProcess;
currentRestyle != lastRestyle;
++currentRestyle) {
ProcessOneRestyle(currentRestyle->mContent,
@ -13259,8 +13261,6 @@ nsCSSFrameConstructor::ProcessPendingRestyles()
currentRestyle->mChangeHint);
}
delete [] restylesToProcess;
EndUpdate();
#ifdef DEBUG