From 0c7b650a86e1d5bf11b067ab3550694438e4ba70 Mon Sep 17 00:00:00 2001 From: "troy%netscape.com" Date: Sun, 12 Mar 2000 03:07:52 +0000 Subject: [PATCH] b=5588. Performance improvement. Avoids walking the child list twice when inserting frames at the head of the list --- layout/base/src/nsFrameList.cpp | 11 +++++++++-- layout/generic/nsFrameList.cpp | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/layout/base/src/nsFrameList.cpp b/layout/base/src/nsFrameList.cpp index 334e547bb5ef..c86561d2dd8d 100644 --- a/layout/base/src/nsFrameList.cpp +++ b/layout/base/src/nsFrameList.cpp @@ -154,16 +154,23 @@ nsFrameList::InsertFrames(nsIFrame* aParent, { NS_PRECONDITION(nsnull != aFrameList, "null ptr"); if (nsnull != aFrameList) { + nsIFrame* lastNewFrame = nsnull; if (nsnull != aParent) { nsIFrame* frame = aFrameList; while (nsnull != frame) { frame->SetParent(aParent); + lastNewFrame = frame; frame->GetNextSibling(&frame); } } - nsFrameList tmp(aFrameList); - nsIFrame* lastNewFrame = tmp.LastChild(); + // Get the last new frame if necessary + if (!lastNewFrame) { + nsFrameList tmp(aFrameList); + lastNewFrame = tmp.LastChild(); + } + + // Link the new frames into the child list if (nsnull == aPrevSibling) { lastNewFrame->SetNextSibling(mFirstChild); mFirstChild = aFrameList; diff --git a/layout/generic/nsFrameList.cpp b/layout/generic/nsFrameList.cpp index 334e547bb5ef..c86561d2dd8d 100644 --- a/layout/generic/nsFrameList.cpp +++ b/layout/generic/nsFrameList.cpp @@ -154,16 +154,23 @@ nsFrameList::InsertFrames(nsIFrame* aParent, { NS_PRECONDITION(nsnull != aFrameList, "null ptr"); if (nsnull != aFrameList) { + nsIFrame* lastNewFrame = nsnull; if (nsnull != aParent) { nsIFrame* frame = aFrameList; while (nsnull != frame) { frame->SetParent(aParent); + lastNewFrame = frame; frame->GetNextSibling(&frame); } } - nsFrameList tmp(aFrameList); - nsIFrame* lastNewFrame = tmp.LastChild(); + // Get the last new frame if necessary + if (!lastNewFrame) { + nsFrameList tmp(aFrameList); + lastNewFrame = tmp.LastChild(); + } + + // Link the new frames into the child list if (nsnull == aPrevSibling) { lastNewFrame->SetNextSibling(mFirstChild); mFirstChild = aFrameList;