Skip to content

Commit 0b95286

Browse files
committed
Add LoadOperation::getLoadInst for readability at the use sites.
And minor implementation cleanup.
1 parent f1bb2e8 commit 0b95286

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

include/swift/SILOptimizer/Utils/OwnershipOptUtils.h

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -345,23 +345,17 @@ struct LoadOperation {
345345

346346
explicit operator bool() const { return !value.isNull(); }
347347

348-
SingleValueInstruction *operator*() const {
348+
SingleValueInstruction *getLoadInst() const {
349349
if (value.is<LoadInst *>())
350350
return value.get<LoadInst *>();
351351
return value.get<LoadBorrowInst *>();
352352
}
353353

354-
const SingleValueInstruction *operator->() const {
355-
if (value.is<LoadInst *>())
356-
return value.get<LoadInst *>();
357-
return value.get<LoadBorrowInst *>();
358-
}
354+
SingleValueInstruction *operator*() const { return getLoadInst(); }
359355

360-
SingleValueInstruction *operator->() {
361-
if (value.is<LoadInst *>())
362-
return value.get<LoadInst *>();
363-
return value.get<LoadBorrowInst *>();
364-
}
356+
const SingleValueInstruction *operator->() const { return getLoadInst(); }
357+
358+
SingleValueInstruction *operator->() { return getLoadInst(); }
365359

366360
SILValue getOperand() const {
367361
if (value.is<LoadInst *>())

0 commit comments

Comments
 (0)