Skip to content

Commit

Permalink
IR: Avoid duplication of SwitchInst::findCaseValue(), NFC
Browse files Browse the repository at this point in the history
Change the non-const version of findCaseValue() to forward to the const
version.
  • Loading branch information
dexonsmith committed Nov 12, 2021
1 parent de2fed6 commit 8b3e1ad
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions llvm/include/llvm/IR/Instructions.h
Expand Up @@ -3515,12 +3515,9 @@ class SwitchInst : public Instruction {
/// default case iterator to indicate that it is handled by the default
/// handler.
CaseIt findCaseValue(const ConstantInt *C) {
CaseIt I = llvm::find_if(
cases(), [C](CaseHandle &Case) { return Case.getCaseValue() == C; });
if (I != case_end())
return I;

return case_default();
return CaseIt(
this,
const_cast<const SwitchInst *>(this)->findCaseValue(C)->getCaseIndex());
}
ConstCaseIt findCaseValue(const ConstantInt *C) const {
ConstCaseIt I = llvm::find_if(cases(), [C](ConstCaseHandle &Case) {
Expand Down

0 comments on commit 8b3e1ad

Please sign in to comment.