[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,28 +14,27 @@
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)
removeFromList();
Value *OldVal = Val;
if (RHS.Val) {
RHS.removeFromList(); RHS.removeFromList();
Val = V2; Val = RHS.Val;
V2->addUse(*this); Val->addUse(*this);
} else { } else {
Val = 0; Val = 0;
} }
if (V1) { if (OldVal) {
RHS.Val = V1; RHS.Val = OldVal;
V1->addUse(RHS); RHS.Val->addUse(RHS);
} else { } else {
RHS.Val = 0; RHS.Val = 0;
} }
}
} }
User *Use::getUser() const { User *Use::getUser() const {