[cleanup] Use early exit and simpler temporary variables to clarify the

swap implementation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202802 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chandler Carruth 2014-03-04 09:00:15 +00:00
parent 4f6b2a26da
commit 775581c418

View File

@ -14,27 +14,26 @@
namespace llvm { namespace llvm {
void Use::swap(Use &RHS) { void Use::swap(Use &RHS) {
Value *V1(Val); if (Val == RHS.Val)
Value *V2(RHS.Val); return;
if (V1 != V2) {
if (V1) {
removeFromList();
}
if (V2) { if (Val)
RHS.removeFromList(); removeFromList();
Val = V2;
V2->addUse(*this);
} else {
Val = 0;
}
if (V1) { Value *OldVal = Val;
RHS.Val = V1; if (RHS.Val) {
V1->addUse(RHS); RHS.removeFromList();
} else { Val = RHS.Val;
RHS.Val = 0; Val->addUse(*this);
} } else {
Val = 0;
}
if (OldVal) {
RHS.Val = OldVal;
RHS.Val->addUse(RHS);
} else {
RHS.Val = 0;
} }
} }