Bug 868557. Explicitly unalias list in nsStyleContext::AddChild() r=dbaron

Clang and GCC probably MSVC are not able to unalias list because they don't
realize that mEmptyChild and mChild can't alias mNextSibling and mPrevSibling.
If we explicitly dereference list we get better code, saving 3 instructions
with clang.
This commit is contained in:
Jeff Muizelaar 2013-05-06 11:05:44 -04:00
Родитель 94799378b3
Коммит d4f0597124
1 изменённых файлов: 10 добавлений и 7 удалений

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

@ -110,17 +110,20 @@ void nsStyleContext::AddChild(nsStyleContext* aChild)
aChild->mNextSibling == aChild,
"child already in a child list");
nsStyleContext **list = aChild->mRuleNode->IsRoot() ? &mEmptyChild : &mChild;
nsStyleContext **listPtr = aChild->mRuleNode->IsRoot() ? &mEmptyChild : &mChild;
// Explicitly dereference listPtr so that compiler doesn't have to know that mNextSibling
// etc. don't alias with what ever listPtr points at.
nsStyleContext *list = *listPtr;
// Insert at the beginning of the list. See also FindChildWithRules.
if (*list) {
if (list) {
// Link into existing elements, if there are any.
aChild->mNextSibling = (*list);
aChild->mPrevSibling = (*list)->mPrevSibling;
(*list)->mPrevSibling->mNextSibling = aChild;
(*list)->mPrevSibling = aChild;
aChild->mNextSibling = list;
aChild->mPrevSibling = list->mPrevSibling;
list->mPrevSibling->mNextSibling = aChild;
list->mPrevSibling = aChild;
}
(*list) = aChild;
(*listPtr) = aChild;
}
void nsStyleContext::RemoveChild(nsStyleContext* aChild)